Skip to content

Instantly share code, notes, and snippets.

@markogresak
Last active June 1, 2017 13:37
Show Gist options
  • Save markogresak/454dfc88e61ce4dfe6ba01529e0246a9 to your computer and use it in GitHub Desktop.
Save markogresak/454dfc88e61ce4dfe6ba01529e0246a9 to your computer and use it in GitHub Desktop.
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-hot-loader": "3.0.0-beta.7",
"react-redux": "^5.0.5",
"react-router-dom": "^4.1.1",
"react-router-redux": "^5.0.0-alpha.6",
"redux": "^3.3.1",
"redux-form": "^6.7.0",
"webpack": "^2.6.1",
"webpack-dev-server": "^2.4.5",
import createHistory from 'history/createBrowserHistory';
import {routerMiddleware} from 'react-router-redux';
import rootReducer from './reducers';
import RootContainer from './components/RootContainer';
// ... rest of imports
const history = createHistory();
const historyMiddleware = routerMiddleware(history);
// ... store configuration
const render = (Component, props) => {
ReactDOM.render(
<AppContainer>
<Component {...props} />
</AppContainer>,
document.getElementById('root')
);
};
render(RootContainer, {history, store});
if (canUseHotReload()) {
module.hot.accept(['./components/RootContainer', './reducers'], () => {
render(RootContainer, {history, store});
});
}
import {Provider} from 'react-redux';
// ... rest of imports
const RootContainer = ({store, history}) => {
return (
<Provider store={store}>
<Routes history={history} />
</Provider>
);
};
// propTypes, export
import {Route, Switch} from 'react-router-dom';
import {ConnectedRouter} from 'react-router-redux';
// ... rest of imports
const Routes = ({history}) => {
return (
<ConnectedRouter history={history}>
<div>
<Switch>
{/* ... */}
</Switch>
</div>
</ConnectedRouter>
);
};
// propTypes, export
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment