-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Components don't re-render when hash location changes #292
Comments
This is not actually an issue, just a misunderstanding of how the router works. The component doesn't get re-initialized and |
Some links worth noting:
If you read #97 you can see my worry that people would get confused, but hopefully they will find this ticket when they start googling. |
I'm facing a similar issue: I access a URL, for example:
I click in an anchor link, so the URL changes and my page scrolls to the anchor, so far so good.
Now, i press the back button in the Browser, the location changes back to Any ideas what's going on? I'm using react-router |
Never mind folks, the problem was with my CSS overriding the default browser behavior with position absolute and overflow hidden. |
@alansouzati yeah the back button takes you back to the place where you came from, that's the expected behaviour. If you want to scroll back to the top you need to handle it yourself. ( |
This may just be an update of the broken link above but an excellent resource is the LifeCycle explanation in react-router's docs: https://github.com/rackt/react-router/blob/master/docs/guides/advanced/ComponentLifecycle.md |
The fact that hash changes don't trigger a render is extremely counter-intuitive and indicative of design flaws in this router. I am now resorting to building my own router. |
Hash changes do trigger a render, BTW. |
fwiw, I ran into the same thing. It came down to me being confused that a nested component wasn't having it's componentWillReceiveProps called. That was happening because I wasn't using all the way down. Once I wrapped components in that who needed to do routing stuff, all was well in the land of code. Nice work on this router guys--really makes decoupling routing from UI slick. Much appreciated. |
When my route changes from
/user/123
to/user/456
my handler doesn't update to reflect the new user ID.The text was updated successfully, but these errors were encountered: