-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathroutes.js
32 lines (28 loc) · 890 Bytes
/
routes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React from 'react';
import { Router, Route } from 'react-router';
import {
fetchData
} from './containers/NewsListing/actions';
import AppWrapper from './containers/AppWrapper';
import NewsListing from './containers/NewsListing';
import HomePage from './containers/HomePage';
import NotFound from './containers/NotFound';
const Routes = (props) => {
const { store } = props;
const getDataNews = (nextState, replace, cb) => {
console.log('nextState', nextState);
const { params: { source } } = nextState;
store.dispatch(fetchData(source));
cb();
};
return (
<Router {...props}>
<Route component={AppWrapper}>
<Route path="/" component={HomePage} />
<Route path="/:source" onEnter={getDataNews} component={NewsListing} />
<Route path="*" component={NotFound} />
</Route>
</Router>
)
};
export default Routes;