-
Notifications
You must be signed in to change notification settings - Fork 641
1.0.0 breaks if history uses basename
option
#103
Comments
Running into this also with #102 and just found the same thing. |
We have a failing test:
*Warning: this just blows the call stack In order to set this up we passed in
|
@dtryon Nice, thanks. I got @hunterc's example to run locally with this change: diff --git a/src/index.js b/src/index.js
index 10cb737..495ec76 100644
--- a/src/index.js
+++ b/src/index.js
@@ -71,6 +71,16 @@ function locationsAreEqual(a, b) {
return a != null && b != null && a.path === b.path && deepEqual(a.state, b.state)
}
+function createPath(location) {
+ const { pathname, search, hash } = location
+ let result = pathname
+ if (search)
+ result += search
+ if (hash)
+ result += hash
+ return result
+}
+
function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) {
const getRouterState = () => selectRouterState(store.getState())
@@ -92,7 +102,7 @@ function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) {
const unsubscribeHistory = history.listen(location => {
const route = {
- path: history.createPath(location),
+ path: createPath(location),
state: location.state
} I'll add your test to the code base and play around with potential solutions. Thanks! |
@dtryon @kjbekkelund thanks for the quick responses! |
That passes the test for me. |
Yep, I think that might the solution for now. I'll create a PR. |
@dtryon @hunterc Fixed in master. I don't have access to release a patch release, so for now you have to rely on master if you want this asap. You can easily set that up in
After
Then you'll have the latest code. |
+1 for releasing this patch. Thanks! |
Can we close this issue if it's been fixed? I'm fine releasing a point release if it's not a breaking change. |
It shouldn't break anything, so should be safe to release a patch. |
Ran into this, really not a fan of having to use master, any chance of a point release happening? |
ditto, ran into this today, and had to roll back |
@kjbekkelund Can we reopen this until it is released under a point release? |
Sure! Sorry about this, I will organize a release today. |
thanks @jlongster |
Sorry, the past few days have been pretty crazy. We are ready to move to the |
Just released 1.0.1 with this fix. |
Hi,
We are currently using
react-router
version 1.0.0createHistory
which imports the browser history strategy.With 0.0.10 all was fine, but upgrading causes a
pushState
to loop forever. :(We are wiring up
basename
like this:Now, when we use
pushState
it loops. I think that the problem is in this code:The
!locationsAreEqual
always returnstrue
because the call tohistory.createPath(location)
comes back with thebasename
prepended.If I debug in the browser, I can see it looping over this case.
I think the solution would be to add this type of thing
lastRoute.changeId !== routing.changeId
like inunsubscribeStore
.I'll see if I can reproduce in a unit test and issue a PR.
The text was updated successfully, but these errors were encountered: