Skip to content

Commit

Permalink
add routing based on react-router
Browse files Browse the repository at this point in the history
  • Loading branch information
denmonzh committed Feb 12, 2019
1 parent 75fd718 commit 3382409
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
18 changes: 14 additions & 4 deletions web/src/containers/Base/Base.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import ProductsTableContainer from 'web-containers/ProductsTableContainer';

import {
Route, Router, Switch,
} from 'react-router'
} from 'react-router';

import createHistory from 'history/createBrowserHistory';
import HomeComponent from 'web-components/HomeComponent';
Expand All @@ -26,9 +26,19 @@ const Base: StatelessFunctionalComponent<*> = (): Node => (
<div>
<Router history={browserHistory}>
<Switch>
<Route path="/" component={HomeComponent} exact />
<Route path="/products" render={() => <ProductsTableContainer browserHistory={browserHistory} />} />
<Route path="/generator" render={() => <ExampleContainer browserHistory={browserHistory} />} />
<Route
path="/"
component={HomeComponent}
exact
/>
<Route
path="/products"
render={() => <ProductsTableContainer browserHistory={browserHistory} />}
/>
<Route
path="/generator"
render={() => <ExampleContainer browserHistory={browserHistory} />}
/>
<Route component={ErrorComponent} />
</Switch>
</Router>
Expand Down
7 changes: 6 additions & 1 deletion web/src/containers/ExampleContainer/ExampleContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ const ExampleContainer = ({ randomString, dispatch, browserHistory }: Props) =>
)
}
/>
<button type="button" onClick={() => browserHistory.goBack()}>Go back</button>
<button
type="button"
onClick={() => browserHistory.goBack()}
>
Go back
</button>
</div>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ const ProductsTableContainer = ({ dataSource, browserHistory }: Props) => (
dataSource={dataSource}
columns={columns}
/>
<button type="button" onClick={() => browserHistory.goBack()}>Go back</button>
<button
type="button"
onClick={() => browserHistory.goBack()}
>
Go back
</button>
</div>

);
Expand Down

0 comments on commit 3382409

Please sign in to comment.