Skip to content

Instantly share code, notes, and snippets.

@hunterc
Last active December 10, 2015 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hunterc/7c8896f7ff05f1928eb5 to your computer and use it in GitHub Desktop.
Save hunterc/7c8896f7ff05f1928eb5 to your computer and use it in GitHub Desktop.
import React from 'react';
import { render } from 'react-dom';
import { createStore, combineReducers } from 'redux';
import { Provider } from 'react-redux';
import { Router, Route, IndexRedirect } from 'react-router';
import { useBasename, createHistory } from 'history';
import { syncReduxAndRouter, routeReducer } from 'redux-simple-router';
const reducer = combineReducers({
routing: routeReducer
});
const store = createStore(reducer);
const history = useBasename(createHistory)({ basename: '/test' });
// without basename seems to work fine
//const history = createHistory();
// if you comment this out everything works
syncReduxAndRouter(history, store);
const A = ({ children }) => (
<div className="a">
{children}
</div>
);
const B = () => (
<div className="b">
<h1>B</h1>
</div>
);
const C = () => (
<div className="c">
<h1>C</h1>
</div>
);
render(
<Provider store={store}>
<Router history={history}>
<Route path="/" component={A}>
<IndexRedirect to="/b" />
<Route path="b" component={B} />
<Route path="c" component={C} />
</Route>
</Router>
</Provider>,
document.getElementById('root')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment