Skip to content

Instantly share code, notes, and snippets.

@hunterc hunterc/routing-bug.js
Last active Dec 10, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.