reactjs / react-router-redux

Ruthlessly simple bindings to keep react-router and redux in sync
https://www.npmjs.com/package/react-router-redux
MIT License
7.81k stars 644 forks source link

Causes reactRouter onUpdate to be double invoked #108

Closed tomatau closed 8 years ago

tomatau commented 8 years ago

When redux-simple-router is setup and a path is updated through a Link or IndexLink from react router, the Router.onUpdate method is double invoked.

If pushPath or updatePath is used, the onUpdate behaves normally.

Here's a branch where it's happening for me onUpdate handler: https://github.com/tomatau/breko-hub/blob/versionUpdates/src/app/entry.js#L33

integration: https://github.com/tomatau/breko-hub/blob/versionUpdates/src/app/state/store.js#L23

navigation: https://github.com/tomatau/breko-hub/blob/versionUpdates/src/app/components/containers/HeadNavigation.js#L23

kimjoar commented 8 years ago

Thanks, @tomatau. Seeing the same in my app when I add a console.log to onUpdate. I'll take a look and see what I find.

kimjoar commented 8 years ago

I've got a failing test, looking for a solution that doesn't break other stuff.

kimjoar commented 8 years ago

@tomatau I found a solution and created a PR. I'll have to think a bit more on it as I'm not entirely sure about the implementation, but hopefully we should have a fix soon.

kimjoar commented 8 years ago

I'm closing this as we're tracking it in #109

tomatau commented 8 years ago

Thanks for addressing this so quickly

kimjoar commented 8 years ago

I re-opened it. #109 already solves a double update, but there might be another problem here. Will look at it tomorrow.

kimjoar commented 8 years ago

@tomatau Maybe you could try out #129 and see if it helps with the double onUpdate?

tomatau commented 8 years ago

When navigating with pushPath, it dispatches @@router/UPDATE_PATH twice, once with state: false, replace: false and the second with state: null, replace: true.

When navigating with a normal Link (history), the @@router/UPDATE_PATH is only dispatched once, but the Router.onUpdate is still double invoked.