From e1345e7ba6d64b032b226d5b8bc295f802f9eafd Mon Sep 17 00:00:00 2001 From: Evan Bacon Date: Thu, 16 Jan 2020 14:59:02 -0800 Subject: [PATCH] Added react-router basic example code --- with-react-router/App.tsx | 48 ++++++++++++++++++------ with-react-router/react-router.native.ts | 6 +++ with-react-router/react-router.ts | 6 +++ with-react-router/web/_redirects | 1 + 4 files changed, 50 insertions(+), 11 deletions(-) create mode 100644 with-react-router/react-router.native.ts create mode 100644 with-react-router/react-router.ts create mode 100644 with-react-router/web/_redirects diff --git a/with-react-router/App.tsx b/with-react-router/App.tsx index d3e692c..e384e10 100644 --- a/with-react-router/App.tsx +++ b/with-react-router/App.tsx @@ -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 = () => Home; + +const About = () => About; + +const App = () => ( + - Open up App.tsx to start working on your app! + + + Home + + + About + + + + + - ); -} + +); 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; diff --git a/with-react-router/react-router.native.ts b/with-react-router/react-router.native.ts new file mode 100644 index 0000000..1e53d6a --- /dev/null +++ b/with-react-router/react-router.native.ts @@ -0,0 +1,6 @@ +export { + NativeRouter as Router, + Switch, + Route, + Link +} from "react-router-native"; \ No newline at end of file diff --git a/with-react-router/react-router.ts b/with-react-router/react-router.ts new file mode 100644 index 0000000..bd35fdc --- /dev/null +++ b/with-react-router/react-router.ts @@ -0,0 +1,6 @@ +export { + BrowserRouter as Router, + Switch, + Route, + Link +} from "react-router-dom"; \ No newline at end of file diff --git a/with-react-router/web/_redirects b/with-react-router/web/_redirects new file mode 100644 index 0000000..ad37e2c --- /dev/null +++ b/with-react-router/web/_redirects @@ -0,0 +1 @@ +/* /index.html 200