Created
April 11, 2023 16:43
-
-
Save Fhernd/a20d4c98f491352ed19c4c758725042a to your computer and use it in GitHub Desktop.
Testing react-router-native
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 { Text, View } from 'react-native'; | |
import { NativeRouter, Switch, Route, Redirect } from 'react-router-native'; | |
const HomeScreen = () => ( | |
<View> | |
<Text>Welcome to the home screen!</Text> | |
</View> | |
); | |
const AboutScreen = () => ( | |
<View> | |
<Text>Welcome to the about screen!</Text> | |
</View> | |
); | |
const NotFoundScreen = () => ( | |
<View> | |
<Text>Sorry, this page was not found.</Text> | |
</View> | |
); | |
const Main = () => { | |
return ( | |
<NativeRouter> | |
<Switch> | |
<Route exact path="/" component={HomeScreen} /> | |
<Route exact path="/about" component={AboutScreen} /> | |
<Redirect from="/old-about" to="/about" /> | |
<Route component={NotFoundScreen} /> | |
</Switch> | |
</NativeRouter> | |
); | |
} | |
export default Main; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment