Last active
August 11, 2019 05:32
-
-
Save cbh6/47c337fa865729268bc535c905820544 to your computer and use it in GitHub Desktop.
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
// you can define router | |
// and add a switch with all routes as a child of a "Main layout component" called app | |
import React from 'react'; | |
import { render } from 'react-dom'; | |
import createHistory from 'history/createBrowserHistory'; | |
import { Router, Route, Redirect, Switch } from 'react-router-dom'; | |
const history = createHistory(); | |
const routes = ( | |
<Router history={history}> | |
<App> | |
<Switch> | |
<Route exact path="/" component={Home} /> | |
<Route exact path="/post" component={PostList} /> | |
<Route path="/showpost/:slug" component={ShowPost} /> | |
<Route path="/page/:slug" component={ShowPage} /> | |
<Route path="/login" component={Login} /> | |
<Route path="/register" component={Register} /> | |
<Route path="/forgotpassword" component={Forgot} /> | |
<Route path="/password/reset/:token" component={Reset} /> | |
<Route path="/logout" component={Logout} /> | |
<Route path="/user" component={User} /> | |
<Route path="/saveorder" render={()=><SaveOrder data={this.state.data}/>} /> | |
</Switch> | |
</App> | |
</Router> | |
); | |
// and then in your app.js component | |
const App = props => ( | |
<div> | |
<Header /> | |
<Menu /> | |
<div> | |
{props.children} | |
</div> | |
</div> | |
); | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment