acdlite / redux-router

Redux bindings for React Router – keep your router state inside your Redux store
MIT License
2.3k stars 200 forks source link

shallowEqual check on params returns false when params doesn't change #139

Closed hakanderyal closed 8 years ago

hakanderyal commented 9 years ago

When using params with:

@connect(state => ({ params: state.router.params }))

the check with shallowEqual

shallowEqual(this.props, nextProps)

return false, when the current and next params are the same.

So the component always re-renders when using shouldComponentUpdate when it should not.

apapirovski commented 9 years ago

It seems like this isn't strictly a redux-router issue. react-router is creating the router object where nested objects are always created anew, even if nothing has changed.

It seems like unnecessary work for redux-router to do selective merging within the store each time ROUTER_DID_CHANGE fires when you could just implement your own shouldComponentUpdate that runs shallowEqual on the actual params. Performance will be much better in this latter scenario.

hakanderyal commented 9 years ago

Thanks for the explanation.

I think we should add it to the docs, if it's not going to be changed.