Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Documentation On Using History with React Router 4 #22

Closed
ds17f opened this issue Jan 3, 2018 · 1 comment
Closed

More Documentation On Using History with React Router 4 #22

ds17f opened this issue Jan 3, 2018 · 1 comment

Comments

@ds17f
Copy link

ds17f commented Jan 3, 2018

I spent a good deal of time suffering with what appeared to be a bug but turned out to be a feature. In short, if you use BrowserRouter in React Router 4 (as much of the documentation suggests) you'll struggle with redux-query-sync.

The docs here make clear that you'll need to use a common history object in order to keep everything in sync and behaving properly. I tried to do this by declaring my own history object and using it in ReduxQuerySync's function call. Then I tried to assign it to my instance of BrowserRouter but it didn't work.

Well it turns out that BrowserRouter creates its own history object and ignores the history that you pass it. It also doesn't throw an error or provide any notification that it is ignoring the property. Instead you need to simply use Router which accepts the history argument. My understanding is that there is no functional difference between BrowserRouter and Router except for the internal declaration of history in the former.

I'm not sure that this is even redux-query-sync's responsibility, but given the time that I spent troubleshooting the issue I figured attaching this issue here might save some poor engineer a few hours in the future.

Otherwise, the library is amazing and exactly the tool I needed for my project.

@Treora
Copy link
Owner

Treora commented Jan 3, 2018

Sorry to hear this got you stuck, and thanks for sharing the experience. The readme now links to this nice explanation, which does mention changing from BrowserRouter to Router, but it is easy to miss this detail. Perhaps we could clarify that explanation and append it to the readme itself. PRs welcome, or else I may do it some day.

@Treora Treora closed this as completed in 365367a Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants