-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Link: listen to history for active state changes #1821
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
Conversation
malte-wessel
commented
Sep 4, 2015
- subscribe to history changes
- don't use the context to pass data
- works with parents that implement shouldComponentUpdate
- solves ActiveState changes don't propagate if any single parent in hierarchy declares shouldComponentUpdate #470, Active link is not updating #1772
modules/Link.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 spaces, should be 2
You are my hero ❤️ @mjackson @ryanflorence Can we please get your eyes on this? I really really want this to get into 1.0. |
niiiiiiiice ;) I was hoping someone would take a stab at this. Thanks @malte-wessel ! I'll take a closer look tomorrow morning. |
@gaearon spaces are fixed, shouldComponentUpdate is in 👍 |
Looks solid to me, @malte-wessel! Thanks for your thoughtful contribution here. It really takes some time to wrap your head around this codebase, and I really appreciate you taking the time to do it :) |
Link: listen to history for active state changes
thank you guys for your awesome work! |
Awesome thanks so much, now I can get rid of an entire store! |
Hmm ... turns out this approach causes another subtle bug. :/ In our tests, we now cannot assert active state on links. Here's what the flow looks like:
So, while I really like the fact that |
@mjackson Can you expand a bit? I don't fully understand what's going on (particularly 2 and 3). Any way I can help? |
Uh, I still don't now how to solve this annoying issue (working active Link inside a subtree with shouldComponentUpdate doing shallowCompare). I don't want to use any workarounds (like fiddling with this.context inside of shouldComponentUpdate or having my own UberLink component). What about at least trying to get the history object from https://github.com/rackt/react-router/blob/master/modules/Link.js#L101 |
You can follow along in the discussion on #470. For my money, though, I think you just shouldn't use |