React Native - WebView

In questo capitolo impareremo come usare WebView. Viene utilizzato quando si desidera eseguire il rendering della pagina Web nella propria app mobile in linea.

Utilizzando WebView

Il HomeContainer sarà un componente contenitore.

App.js

import React, { Component } from 'react'
import WebViewExample from './web_view_example.js'

const App = () => {
   return (
      <WebViewExample/>
   )
}
export default App;

Creiamo un nuovo file chiamato WebViewExample.js dentro il src/components/home cartella.

web_view_example.js

import React, { Component } from 'react'
import { View, WebView, StyleSheet }

from 'react-native'
const WebViewExample = () => {
   return (
      <View style = {styles.container}>
         <WebView
         source = {{ uri:
         'https://www.google.com/?gws_rd=cr,ssl&ei=SICcV9_EFqqk6ASA3ZaABA#q=tutorialspoint' }}
         />
      </View>
   )
}
export default WebViewExample;

const styles = StyleSheet.create({
   container: {
      height: 350,
   }
})

Il programma precedente genererà il seguente output.