React Native
React Native – WebView
React Native WebView is a component to render the web page into your mobile app. This is supported by Android and IOs both. WebView is very useful as you can open any web link in your app itself so when anybody wants to browse your referred link they don’t need to open any other app for that.
import { WebView} from 'react-native-webview'
source | injectJavaScript | injectedJavaScript | onError |
onLoad | onLoadEnd | onLoadStart | onMessage |
originWhitelist | renderError | style | userAgent |
html | url | geolocationEnabled | scrollEnabled |
contentInset | bounces | allowFileAccess | nativeConfig |
<WebView source={{uri: 'https://blog.codehunger.in'}}/>
To use WebView
you need to install react-native-webview
dependency.
npm install react-native-webview --save
After the updation of React Native 0.60, they have introduced autolinking so we do not require to link the library but need to install pods. So to install pods use
cd ios && pod install && cd ..
//This is an example code to understand WebView//
import React, { Component } from 'react';
//import react in our code.
import { WebView } from "react-native-webview";
//import all the components we are going to use.
export default class App extends Component {
render() {
return (
<WebView
source={{uri: 'https://blog.codehunger.in'}}
style={{marginTop: 20}}
/>
);
}
}