Created
March 22, 2019 20:46
-
-
Save littleV/cba77f7836af02dc0fcbda8f97df7346 to your computer and use it in GitHub Desktop.
A React Native WebView Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { Button, View, Text, WebView } from "react-native"; | |
import { createStackNavigator, createAppContainer } from "react-navigation"; | |
class HomeScreen extends React.Component { | |
render() { | |
return ( | |
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> | |
<Text>Home Screen</Text> | |
<Button | |
title="Go to Details" | |
onPress={() => this.props.navigation.navigate('Details')} | |
/> | |
</View> | |
); | |
} | |
} | |
class DetailsScreen extends React.Component { | |
render() { | |
return ( | |
<WebView | |
source={{uri: 'https://www.google.com'}} | |
style={{marginTop: 20}} | |
/> | |
); | |
} | |
} | |
const AppNavigator = createStackNavigator( | |
{ | |
Home: HomeScreen, | |
Details: DetailsScreen | |
}, | |
{ | |
initialRouteName: "Home" | |
} | |
); | |
export default createAppContainer(AppNavigator); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment