You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
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 betweenBrowserRouter
andRouter
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.
The text was updated successfully, but these errors were encountered: