Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created April 11, 2023 16:43
Show Gist options
  • Save Fhernd/a20d4c98f491352ed19c4c758725042a to your computer and use it in GitHub Desktop.
Save Fhernd/a20d4c98f491352ed19c4c758725042a to your computer and use it in GitHub Desktop.
Testing react-router-native
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