This repository was archived by the owner on Oct 26, 2018. It is now read-only.
This repository was archived by the owner on Oct 26, 2018. It is now read-only.
Does not work with history@^3 #385
Closed
Description
Using:
- react-router-redux@v4.0.4
- history@3.0.0-2
Original issue description (relevant):
I have spent a good 3 hours trying to understand the underlying issue, but have not found anything that would strike as incompatible. All docs include a variation of this setup that is supposed to work:
import React from 'react'; import ReactDOM from 'react-dom'; import { Provider } from 'react-redux'; import store from './store'; import { Route, Router, useRouterHistory } from 'react-router'; import { createHistory } from 'history'; import { syncHistoryWithStore } from 'react-router-redux'; const browserHistory = useRouterHistory(createHistory)(); const history = syncHistoryWithStore(browserHistory, store, { selectLocationState (state) { return state.getIn(['route']).toJS(); } }); history.listen((location) => { console.log('location', location); }); ReactDOM.render(<Provider store={store}> <Router history={history}> <Route path='*' component={() => { console.log('Hello!'); }}> <div>Hello!</div> </Route> </Router> </Provider>, document.querySelector('#app'));However, using
browserHistory
exported fromreact-router
works without an issue:import React from 'react'; import ReactDOM from 'react-dom'; import { Provider } from 'react-redux'; import store from './store'; import { Route, Router, // useRouterHistory browserHistory } from 'react-router'; import { createHistory } from 'history'; import { syncHistoryWithStore } from 'react-router-redux'; // const browserHistory = useRouterHistory(createHistory)(); const history = syncHistoryWithStore(browserHistory, store, { selectLocationState (state) { return state.getIn(['route']).toJS(); } }); history.listen((location) => { console.log('location', location); }); ReactDOM.render(<Provider store={store}> <Router history={history}> <Route path='*' component={() => { console.log('Hello!'); }}> <div>Hello!</div> </Route> </Router> </Provider>, document.querySelector('#app'));When I say "does not work", I mean:
history.listen
logslocation
asundefined
.- No routes are resolved.
When I say "works", I mean:
history.listen
logslocation
as:{pathname: "/", search: "", hash: "", state: null, action: "POP"…}
*
route is resolved.>
Metadata
Metadata
Assignees
Labels
No labels