Skip to content
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.

1.0.0 breaks if history uses basename option #103

Closed
@dtryon

Description

@dtryon

Hi,
We are currently using react-router version 1.0.0 createHistory 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:

const history = useBasename(createHistory)({basename: '/foobar'});

Now, when we use pushState it loops. I think that the problem is in this code:

} else if(!locationsAreEqual(getRouterState(), route)) {
      // The above check avoids dispatching an action if the store is
      // already up-to-date
      const method = location.action === 'REPLACE' ? replacePath : pushPath
      store.dispatch(method(route.path, route.state, { avoidRouterUpdate: true }))
    }

The !locationsAreEqual always returns true because the call to history.createPath(location) comes back with the basename 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 in unsubscribeStore.

I'll see if I can reproduce in a unit test and issue a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions