-
Notifications
You must be signed in to change notification settings - Fork 756
Why unmount on page change? #296
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
Comments
Someone else can correct me if I'm wrong, but I understood that the motivation is so that multiple calls to |
My question was regarding the last part of that sentence to do with the unmounting on page unload. A full page change always blows away the DOM and starts again, can't think of a valid reason for doing extra work and causing re-rendering / painting before navigating. For things like turbolinks this may make sense but there's special events you can use in those cases. Specifically why the need to unmount in handleNativeEvents here |
For me, it just seems like the "right" thing to do: React components have lifecycle hooks and it seems good to run through them. If people want to skip those lifecycle hooks, ok, go for it, but executing them seems like a good default behavior. I imagine another simple work around would be:
Do you know how any other React + server framework libraries handle it? Do they unmount on unload? |
Disagree with you there, it's the wrong thing to do on page unload. The only time it makes sense is for single page apps. The way it behaves currently is really strange from a ux perspective and just unnecessary work for the browser slowing down page changes. |
I definitely see your point, I'm open to a PR with a better handling of this case! |
"On page load, the react_ujs driver will scan the page and mount components using data-react-class and data-react-props. Before page unload, it will unmount components (if you want to disable this behavior, remove data-react-class attribute in componentDidMount)."
Why is this the default? Removing chunks of the DOM when changing pages seems strange.
The text was updated successfully, but these errors were encountered: