React-router: <Link /> not rerendering after a route change

Created on 8 Jun 2016  路  3Comments  路  Source: ReactTraining/react-router

Version

2.4.0

I have a project with a lot around react-router (react-router-redux among other things) so I'm still trying to isolate the problem but I'm posting the issue in the meantime if someone is having the same problem at the same time... or even an idea of where to look for.

Test Case

Clicking on a <Link /> in a header

Steps to reproduce

_Working on it_

Expected Behavior

The active style being added to the Link I just clicked and removed from the Link of the route we just left.

Actual Behavior

Rendering the right component but since no props changed in my header's Link they don't re-render. By adding Link.componentDidMount = () => this.context.router.listen(this.render.bind(this)) it re-render but is always keeping the active style once it has been active once.

Most helpful comment

Thanks for the info mate :D

I don't know if you've seen but they said that the problem should be fix with react-router@next and 3.0. It worked for me :)

Cheers gaulucky !

All 3 comments

After using JSBin, the problem doesn't reproduce, so the problem is probably coming from the combinaison with react-router-redux or just in my set-up. I'll continue to work on that

http://jsbin.com/dezofayagu/1/edit?html,js,output

I got this issue too, and after searching for the answer, I think it might be something related to Redux. As being discussed at #3536 , a container component which is wrapped by Redux's connect() will make all the Links in it fail to change their active state. Also in the comment section @mertkahyaoglu said that he would simply put an option {pure: false} to connect() but it does not work for me.

Thanks for the info mate :D

I don't know if you've seen but they said that the problem should be fix with react-router@next and 3.0. It worked for me :)

Cheers gaulucky !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ackvf picture ackvf  路  3Comments

nicolashery picture nicolashery  路  3Comments

davetgreen picture davetgreen  路  3Comments

Radivarig picture Radivarig  路  3Comments

alexyaseen picture alexyaseen  路  3Comments