updated Root to App, extracting provider and router
This commit is contained in:
parent
6097dc492e
commit
17a5e436b7
3 changed files with 34 additions and 36 deletions
22
react/app.js
Normal file
22
react/app.js
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { Route, Switch } from 'react-router-dom';
|
||||||
|
import PublishPage from 'components/PublishPage';
|
||||||
|
import AboutPage from 'components/AboutPage';
|
||||||
|
import LoginPage from 'containers/LoginPage';
|
||||||
|
import ShowPage from 'containers/ShowPage';
|
||||||
|
import FourOhFourPage from 'components/FourOhFourPage';
|
||||||
|
|
||||||
|
const App = () => {
|
||||||
|
return (
|
||||||
|
<Switch>
|
||||||
|
<Route exact path="/" component={PublishPage} />
|
||||||
|
<Route exact path="/about" component={AboutPage} />
|
||||||
|
<Route exact path="/login" component={LoginPage} />
|
||||||
|
<Route exact path="/:identifier/:claim" component={ShowPage} />
|
||||||
|
<Route exact path="/:claim" component={ShowPage} />
|
||||||
|
<Route component={FourOhFourPage} />
|
||||||
|
</Switch>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default App;
|
|
@ -1,10 +1,14 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { render } from 'react-dom';
|
import { render } from 'react-dom';
|
||||||
|
import { Provider } from 'react-redux';
|
||||||
import { createStore, applyMiddleware, compose } from 'redux';
|
import { createStore, applyMiddleware, compose } from 'redux';
|
||||||
|
import { BrowserRouter } from 'react-router-dom';
|
||||||
import Reducer from 'reducers';
|
import Reducer from 'reducers';
|
||||||
import createSagaMiddleware from 'redux-saga';
|
import createSagaMiddleware from 'redux-saga';
|
||||||
import rootSaga from 'sagas';
|
import rootSaga from 'sagas';
|
||||||
import Root from './root';
|
|
||||||
|
import GAListener from 'components/GAListener';
|
||||||
|
import App from './app';
|
||||||
|
|
||||||
const sagaMiddleware = createSagaMiddleware();
|
const sagaMiddleware = createSagaMiddleware();
|
||||||
const middleware = applyMiddleware(sagaMiddleware);
|
const middleware = applyMiddleware(sagaMiddleware);
|
||||||
|
@ -19,6 +23,12 @@ let store = createStore(
|
||||||
sagaMiddleware.run(rootSaga);
|
sagaMiddleware.run(rootSaga);
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<Root store={store} />,
|
<Provider store={store}>
|
||||||
|
<BrowserRouter>
|
||||||
|
<GAListener>
|
||||||
|
<App />
|
||||||
|
</GAListener>
|
||||||
|
</BrowserRouter>
|
||||||
|
</Provider>,
|
||||||
document.getElementById('react-app')
|
document.getElementById('react-app')
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { Provider } from 'react-redux';
|
|
||||||
import { BrowserRouter, Route, Switch } from 'react-router-dom';
|
|
||||||
|
|
||||||
import GAListener from 'components/GAListener';
|
|
||||||
import PublishPage from 'components/PublishPage';
|
|
||||||
import AboutPage from 'components/AboutPage';
|
|
||||||
import LoginPage from 'containers/LoginPage';
|
|
||||||
import ShowPage from 'containers/ShowPage';
|
|
||||||
import FourOhFourPage from 'components/FourOhFourPage';
|
|
||||||
|
|
||||||
const Root = ({ store }) => (
|
|
||||||
<Provider store={store}>
|
|
||||||
<BrowserRouter>
|
|
||||||
<GAListener>
|
|
||||||
<Switch>
|
|
||||||
<Route exact path="/" component={PublishPage} />
|
|
||||||
<Route exact path="/about" component={AboutPage} />
|
|
||||||
<Route exact path="/login" component={LoginPage} />
|
|
||||||
<Route exact path="/:identifier/:claim" component={ShowPage} />
|
|
||||||
<Route exact path="/:claim" component={ShowPage} />
|
|
||||||
<Route component={FourOhFourPage} />
|
|
||||||
</Switch>
|
|
||||||
</GAListener>
|
|
||||||
</BrowserRouter>
|
|
||||||
</Provider>
|
|
||||||
);
|
|
||||||
|
|
||||||
Root.propTypes = {
|
|
||||||
store: PropTypes.object.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Root;
|
|
Loading…
Reference in a new issue