mirror of
https://github.com/zhigang1992/examples.git
synced 2026-01-12 17:13:21 +08:00
Added react-router basic example code
This commit is contained in:
@@ -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;
|
||||
|
||||
6
with-react-router/react-router.native.ts
Normal file
6
with-react-router/react-router.native.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export {
|
||||
NativeRouter as Router,
|
||||
Switch,
|
||||
Route,
|
||||
Link
|
||||
} from "react-router-native";
|
||||
6
with-react-router/react-router.ts
Normal file
6
with-react-router/react-router.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export {
|
||||
BrowserRouter as Router,
|
||||
Switch,
|
||||
Route,
|
||||
Link
|
||||
} from "react-router-dom";
|
||||
1
with-react-router/web/_redirects
Normal file
1
with-react-router/web/_redirects
Normal file
@@ -0,0 +1 @@
|
||||
/* /index.html 200
|
||||
Reference in New Issue
Block a user