Note Remember the following when using WebView:
Facebook has deprecated WebView
.
For continued support past its removal by Facebook, import the You.i React Native WebView
component from react-native-youi
.
The WebView component renders any web content in a native view.
Due to Facebook deprecating this component, we recommend importing WebView
from react-native-youi
.
import { WebView } from 'react-native';
...
<WebView
source={{uri: 'https://en.wikipedia.org/wiki/React_(JavaScript_library)'}}
onLoad={() => this.setState({loadingOccurred: true})}
onError={() => this.setState({ errorOccurred: true })}
onLoadStart={() => this.setState({ loadingStarted: true })}
onLoadEnd={() => this.setState({ loadingEnded: true })}
onNavigationStateChange={() => this.setState({ navigationStateChange: true })}
bounces={this.state.bounceAllowed}
scrollEnabled= {this.state.scrollAllowed}
decelerationRate={this.state.decelerationSpeed}
renderError={(e) => {
console.log("You.i: Render Error! The url may be invalid, or the connection timed out");
return (
<View style={styles.container}>
<Text style={styles.text}> This is the renderError View! </Text>
</View>
);
}}
startInLoadingState={true}
renderLoading={(e) => {
return (
<View style={styles.container}>
<Image source={{uri: "https://codepen.io/biacosta/pen/QwBdBB/image/large.png"}}
style={{width:1024, height:600, bottom:340, left: 140 }}
/>
</View>
);
}}
/>
[source: object] (#prop-source)
[onError: function] (#prop-onerror)
[onLoad: function] (#prop-onload)
[onLoadEnd: function] (#prop-onloadend)
[onLoadStart: function] (#prop-onloadstart)
[onNavigationStateChange: function] (#prop-onnavigationstatechange)
[renderError: function] (#prop-rendererror)
[renderLoading: function] (#prop-renderloading)
[startInLoadingState: boolean] (#prop-startinloadingstate)
[decelerationRate: number] (#prop-decelerationrate)
[bounces: boolean] (#prop-bounces)
[scrollEnabled: boolean] (#prop-scrollenabled)
source
Similar to source prop of Facebook React Native WebView component.
onError
Similar to onError prop of Facebook React Native WebView component.
onLoad
Similar to onLoad prop of Facebook React Native WebView component.
onLoadEnd
Similar to onLoadEnd prop of Facebook React Native WebView component.
onLoadStart
Similar to onLoadStart prop of Facebook React Native WebView component.
onNavigationStateChange
Similar to onNavigationStateChange prop of Facebook React Native WebView component.
renderError
Similar to renderError prop of Facebook React Native WebView component.
renderLoading
Similar to renderLoading prop of Facebook React Native WebView component.
startInLoadingState
Similar to startInLoadingState prop of Facebook React Native WebView component.
decelerationRate
Similar to decelerationRate prop of Facebook React Native WebView component.
Note It is supported on iOS only.
bounces
Similar to bounces prop of Facebook React Native WebView component.
Note It is supported on iOS only.
scrollEnabled
Similar to scrollEnabled prop of Facebook React Native WebView component.
Note It is supported on iOS only.