Last active
December 10, 2015 15:44
-
-
Save hunterc/7c8896f7ff05f1928eb5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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