Added react-router basic example code

This commit is contained in:
Evan Bacon
2020-01-16 14:59:02 -08:00
parent 146e891fb1
commit e1345e7ba6
4 changed files with 50 additions and 11 deletions

View File

@@ -1,19 +1,45 @@
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import React from "react";
import { StyleSheet, Text, View, Platform } from "react-native";
export default function App() {
return (
import {
Router,
Switch,
Route,
Link
} from "./react-router";
const Home = () => <Text>Home</Text>;
const About = () => <Text>About</Text>;
const App = () => (
<Router>
<View style={styles.container}>
<Text>Open up App.tsx to start working on your app!</Text>
<View style={styles.nav}>
<Link to="/">
<Text>Home</Text>
</Link>
<Link to="/about">
<Text>About</Text>
</Link>
</View>
);
}
<Route exact path="/" component={Home} />
<Route path="/about" component={About} />
</View>
</Router>
);
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
marginTop: 25,
padding: 10
},
nav:{
flexDirection: 'row',
justifyContent: 'space-around',
}
});
export default App;

View File

@@ -0,0 +1,6 @@
export {
NativeRouter as Router,
Switch,
Route,
Link
} from "react-router-native";

View File

@@ -0,0 +1,6 @@
export {
BrowserRouter as Router,
Switch,
Route,
Link
} from "react-router-dom";

View File

@@ -0,0 +1 @@
/* /index.html 200