Skip to content
This repository has been archived by the owner on Oct 26, 2018. It is now read-only.

Using <Link> seems to set avoidRouterUpdate to true automatically #71

Closed
jchristianhall opened this issue Dec 3, 2015 · 7 comments
Closed

Comments

@jchristianhall
Copy link

Dropped in this library and it worked like a charm. However, I just noticed that every instance of a has been setting avoidRouterUpdate. Any idea how I can prevent this behaviour?

@jchristianhall
Copy link
Author

Okay, maybe not every instance. Looked through the source, and this is happening because of lines 72-87. I'm transitioning from a route based on ids. /people/1 to people/12, for example. Do I need to dispatch an action and force the update rather than use <Link> here?

@kimjoar
Copy link
Collaborator

kimjoar commented Dec 4, 2015

Is there anything that breaks for you? avoidRouterUpdate is only used internally in the library to know when and what to update (check out #50 if you want more of the low-level details). When you use the <Link>, does the back button work as expected?

@jchristianhall
Copy link
Author

<Link> seems to function normally. I'm using hash history right now, and it updates the url whenever I change states. Back button works as expected. @@router/UPDATE_PATH is firing on every change, but the action is passing avoidRouterUpdate as true whenever I go between routes using the same <Route path="people/:id">. Switching between other routes works great, so it's only this instance that has the unexpected behaviour.

@kimjoar
Copy link
Collaborator

kimjoar commented Dec 4, 2015

If you follow a <Link> is is expected that avoidRouterUpdate == true and if you dispath an event it should be false. Read about cycles in #50 to understand why. Btw, there's been a lot of commits on master lately, so it might be that 0.0.10 is out of sync with this (I rely on master, not on 0.0.10 in my app right now, while waiting for the upcoming release).

But eitherway: the value of avoidRouterUpdate is only expected to be used internally in the lib, so it's value in itself shouldn't be unexpected (as long as the lib works as it should, of course).

@jchristianhall
Copy link
Author

Ah. I guess I missed the bit about <Link> setting avoidRouterUpdate: true when I was reading through. After testing out a few routes, it is consistently passing that value in every action. Looks like I've incorrectly titled this issue.

The problem I'm running into is that switching between the same <Route> isn't triggering componentWillMount to pull new data. I'd assume the component is already mounted because it's the component being supplied to the <Route>. However, that lifecycle function was called when I was only using react-router. It only started behaving differently with the introduction of redux-simple-router.

@kimjoar
Copy link
Collaborator

kimjoar commented Dec 4, 2015

Ah, okey, so the problem is with lifecycle hooks. So you're using <Link> to go between /people/1 and /people/12? If so I would not expect componentWillMount to trigger when using React Router, I would expect componentWillReceiveProps to trigger (depending of course on other logic in your app). See https://github.com/rackt/react-router/blob/master/docs/guides/advanced/ComponentLifecycle.md#lifecycle-hooks-when-routing for how the lifecycle is expected to work (and specifically item 3 in this case).

@jchristianhall
Copy link
Author

Hmm. Somehow lost that function during the refactoring. That fixed it. Thanks for the help!

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

2 participants