-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Reload routes #3770
Comments
Currently I do this:
and I hate these 3 lines in my code. Using these lines introduce new problems for me on hot reloading which is beyond the scope of this thread. |
That is currently the best way to do it. React is built around doing a noop if the state and props provided are the same between renders. |
Sorry @timdorr , I didn't understand why this feature request got rejected.
Even changing props of that component doesn't make it render the new component and the fact that changing location to '/' and then changing it back renders new component makes me think implementing this feature is feasible with current version of react and doesn't require any change in react library. |
It's not rejected. This is a dupe of #2182. |
No it's not. I don't want to change routes, I just want to re-render the page with my updated component. I hope some day core developers of For others who don't care if their whole project follows functional paradigm like me and have too much problems with the absence of The method I described in my first comment is by no means best solution, not currently nor never. We want a method to call which re-renders the page with the new version of components (or you may have your own reasons to re-render page, I don't ask why, I don't try to teach you that it's wrong or right because I know nor me nor no one is in a position to do so, I don't try to convince you to solve everything by providing new props and states, I just respect your decision and I'm sure you have your own valid reasons and you have better considerations about your own projects than any others.) I were able to simulate the beloved imperative method this way: If you're using redux and If you're using bare
If it didn't work just open ReactDevTools and try to find the outer most component in the hierarchy which doesn't re-render. Then try to convince it to re-render by changing a prop in it. |
Why not just |
Thanks for reply. Sorry for long comment, I try to be descriptive.
Suppose this structure: (I use arrow functions just to simplify, the real project uses classes if that matters.)
Now suppose that I change
I thought it would be the case too. After all consider that my data didn't change, the thing that is changed is the component itself. What should be done is 1) the reference of the component instance should get updated with the new instance of the new component. Which I think could be achieved if Making router call |
The code I provided above is just schematic and may have problems but I guess it gives you an idea about what's going on. |
Meanwhile I appreciate if you reopen this issue till I'm convinced it's solved or is not solvable or is addressed in another open issue or at least you yourself (or any other repo owner) think you have provided enough information to convince me but for any reason I didn't get convinced. |
You've already identified the antecedent issue here. This remains a duplicate issue. |
That issue is closed, if that's the case then please open that issue and I'll migrate the conversation there. |
Suppose that I'm using getComponent on some routes, when I'm using live reload, after reload is done it I need getComponent to run again (it'll call callback with the new component) so that it renders the new component. So I need a
reload
method on router which asks it to re-render the page (calling getComponent is part of it). It's discussed here: #1982 but that's a closed issue and it seems no one read my comment there. Let me know if I should provide additional information.The text was updated successfully, but these errors were encountered: