Skip to content

Conversation

malte-wessel
Copy link

modules/Link.js Outdated
Copy link
Contributor

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

@gaearon
Copy link
Contributor

gaearon commented Sep 4, 2015

You are my hero ❤️

@mjackson @ryanflorence Can we please get your eyes on this? I really really want this to get into 1.0.

@gaearon gaearon added this to the 1.0.0 milestone Sep 4, 2015
@mjackson
Copy link
Member

mjackson commented Sep 5, 2015

niiiiiiiice ;) I was hoping someone would take a stab at this. Thanks @malte-wessel ! I'll take a closer look tomorrow morning.

@malte-wessel
Copy link
Author

@gaearon spaces are fixed, shouldComponentUpdate is in 👍

@mjackson
Copy link
Member

mjackson commented Sep 5, 2015

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 :)

mjackson added a commit that referenced this pull request Sep 5, 2015
Link: listen to history for active state changes
@mjackson mjackson merged commit 1d81520 into remix-run:master Sep 5, 2015
@malte-wessel
Copy link
Author

thank you guys for your awesome work!

@roundrobin
Copy link

Awesome thanks so much, now I can get rid of an entire store!

@mjackson
Copy link
Member

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:

  1. we get a new location
  2. <Router> picks up the change and updates its state, causing a re-render
  3. we assert that links have the correct active state (and fail)
  4. <Link>s get the location change and update their active state

So, while I really like the fact that <Link>s now work as descendants of components that return false from shouldComponentUpdate, I'm afraid we're going to have to think of another solution for this particular problem. We have reverted these changes in 50372fe.

@gaearon
Copy link
Contributor

gaearon commented Sep 13, 2015

@mjackson Can you expand a bit? I don't fully understand what's going on (particularly 2 and 3). Any way I can help?

@tajo
Copy link

tajo commented Oct 12, 2015

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 this.props.history if this.context.history does not exist? It's should be one-liner. Then I could just pass the history object as a prop. It is still kinda workaround but clean.

https://github.com/rackt/react-router/blob/master/modules/Link.js#L101

@taion
Copy link
Contributor

taion commented Oct 12, 2015

You can follow along in the discussion on #470. For my money, though, I think you just shouldn't use shallowCompare on those subtrees. If you embed a Link, the parents of the Link are not really "pure".

@lock lock bot locked as resolved and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants