2018-11-06 23:19:17 +07:00
|
|
|
import React, { Component } from 'react';
|
2019-01-26 21:29:12 +07:00
|
|
|
import './App.scss';
|
2018-11-06 23:19:17 +07:00
|
|
|
|
2019-01-26 21:29:12 +07:00
|
|
|
import { Route, Switch } from "react-router-dom";
|
2019-01-11 03:43:21 +07:00
|
|
|
import { routes } from './routes/index';
|
|
|
|
import { createBrowserHistory } from 'history';
|
2019-01-20 02:10:43 +07:00
|
|
|
import { createStore, applyMiddleware, compose } from 'redux';
|
2019-01-14 03:35:46 +07:00
|
|
|
import reducer from './reducers';
|
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
import thunk from 'redux-thunk';
|
2019-01-20 02:10:43 +07:00
|
|
|
import { routerMiddleware, ConnectedRouter } from 'connected-react-router';
|
2019-01-11 03:43:21 +07:00
|
|
|
|
|
|
|
const history = createBrowserHistory();
|
2019-01-14 03:35:46 +07:00
|
|
|
const store = createStore(
|
2019-01-20 02:10:43 +07:00
|
|
|
reducer(history),
|
|
|
|
compose(
|
|
|
|
applyMiddleware(
|
|
|
|
routerMiddleware(history),
|
|
|
|
thunk
|
|
|
|
)
|
|
|
|
)
|
2019-01-14 03:35:46 +07:00
|
|
|
);
|
2018-11-06 23:19:17 +07:00
|
|
|
|
|
|
|
class App extends Component {
|
|
|
|
render() {
|
|
|
|
return (
|
2019-01-14 03:35:46 +07:00
|
|
|
<Provider store={store}>
|
2019-01-20 02:10:43 +07:00
|
|
|
<ConnectedRouter history={history}>
|
2019-01-14 03:35:46 +07:00
|
|
|
<div className="App">
|
|
|
|
<Switch>
|
|
|
|
{routes.map((r, key) => {
|
|
|
|
return <Route path={r.path} component={r.component} key={key}/>
|
|
|
|
})}
|
|
|
|
</Switch>
|
|
|
|
</div>
|
2019-01-20 02:10:43 +07:00
|
|
|
</ConnectedRouter>
|
2019-01-14 03:35:46 +07:00
|
|
|
</Provider>
|
2018-11-06 23:19:17 +07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default App;
|