Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Active routes not changing when used with react-redux #3536

Closed
mertkahyaoglu opened this issue Jun 12, 2016 · 11 comments
Closed

Active routes not changing when used with react-redux #3536

mertkahyaoglu opened this issue Jun 12, 2016 · 11 comments

Comments

@mertkahyaoglu
Copy link

Only initial route gets active class but when I change the route, it is still showing the first route as active.
This happens when the component containing Links is wrapped with connect like this;

export default connect(mapStateToProps, mapDispatchToProps)(Sidebar);

But when I export it as a plain component like this;

export default Sidebar;

Active links are changing correctly. Is this a bug or am I missing something?

Versions;
react-router: 2.4.0,
react-router-redux: ^4.0.4

@taion
Copy link
Contributor

taion commented Jun 12, 2016

See previous discussions around link and pure containers.

@taion taion closed this as completed Jun 12, 2016
@timdorr
Copy link
Member

timdorr commented Jun 12, 2016

Note that this is fixed in react-router@next and 3.0.

@jimbolla
Copy link

@timdorr Any chance you can point me to the changes that made it work? I'd like to see just for educational purposes.

@mertkahyaoglu
Copy link
Author

@jimbolla This one worked for me. Basically you pass {pure:false} to connect like this;

export default connect(mapStateToProps, mapDispatchToProps, null, {pure:false})(Sidebar);

@timdorr
Copy link
Member

timdorr commented Jun 13, 2016

See the tail end of #470 and #3430

@paustria
Copy link
Contributor

paustria commented Aug 4, 2016

FYI. I can reproduce this again on
"react-router": "2.6.0",
"react-router-redux": "4.0.5"

@taion
Copy link
Contributor

taion commented Aug 4, 2016

Please read earlier comments on the issue.

@paustria
Copy link
Contributor

paustria commented Aug 4, 2016

@taion I read it. So, this is expected behavior until you pass {pure:false}?

@taion
Copy link
Contributor

taion commented Aug 4, 2016

That's how React context works. For reasons of avoiding breakage per semver, we cannot ship the workaround for this in the 2.x line.

@billyshena
Copy link

I'm currently also facing this issue and used {pure:false} as a workaround.
However, I can notice a little delay between active class being set.
Should we upgrade react-router to the 3.X version to avoid this performance issue?

Best,

@petermikitsh
Copy link
Contributor

Thanks @mertkahyaoglu, that solution works for me with react-router@2.8.1 and react-redux@4.4.5.

mertkahyaoglu added a commit to jekyll/jekyll-admin that referenced this issue Dec 24, 2016
[this issue](remix-run/react-router#3536)
is fixed with react-router v3.0.0
cdunn6754 added a commit to cdunn6754/reReddit_frontend that referenced this issue Nov 7, 2018
There is some problem with the combination of react-router
and react-bootstrap that causes a single nav link, e.g. users or
subs, to be stuck activated regardless of the actual current url.

I found a fix here
remix-run/react-router#3536
and an explanation here
https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/guides/blocked-updates.md
@remix-run remix-run deleted a comment from mraliyev Nov 14, 2018
@remix-run remix-run locked as resolved and limited conversation to collaborators Nov 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants