-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Fix issue with node refs and hydration #2597
Conversation
Visit the preview URL for this PR (updated for commit 9af8012): https://yew-rs-api--pr2597-hydration-node-refs-oq11ixgp.web.app (expires Tue, 19 Apr 2022 00:25:13 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
Size Comparison
|
This solved my issue, both in the example and my real app |
When a component is contained in a component, the inner reconciles, which used to replace the NodeRef, which left a badly linked one in the outer Hydration render state. Now, keep a stable internal_ref besides the user-passed node_ref. The internal_ref never gets replaced as long as the BComp lives.
e5e85d5
to
e8767e8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment in the code stating why/how internal_ref
and node_ref
are different would be helpful and nice to have. You can merge it as-is and add the explainer in your other PR if you want to.
9af8012
This reverts commit 469cc34.
…oved (#2629) * Separate hydration and render queue. * Revert "Fix issue with node refs and hydration (#2597)" This reverts commit 469cc34. * Priority Render. * Add some tests. * Add more tests. * Add test result after click. * Fix test comment. * Fix test timing. * Restore test. * Once AtomicBool, now a Cell. * Prefer use_future. * Revealing of Suspense always happen after the component has re-rendered itself. * Shifting should register correct next_sibling. * Revert to HashMap. * cargo +nightly fmt. * Fix comment. * Optimise Code size? * Add comment if assertion fails. * Revert "Merge branch 'hydration-4' into fc-prepared-state" This reverts commit 427b087d4db6b2e497ad618273655bd18ba9bd01, reversing changes made to 109fcfa. * Revert "Revert "Merge branch 'hydration-4' into fc-prepared-state"" This reverts commit f1e4089. * Redo #2957.
Description
When a component is contained in a component, the inner reconciles on its (actual, non-hydration)
first_render,
replacing thenode_ref
pointing to the rendered node. This left a badly linkedNodeRef
in the outer component's render state.Now, keep a stable internal_ref besides the user-passed node_ref. The internal_ref never gets replaced as long as the BComp lives.
Fixes #2596
As an aside: Note that using
internal_ref
is also part of the machinery contained in the other component ref PR by me.Checklist
cargo make pr-flow