-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Problem
This was reported on discord first.
A full reproduction is in https://github.com/Madoshakalaka/render-order-dom-slot-panic
Steps To Reproduce
Have a component with an inherently unstable render order, such as using the iteration order of HashMap to order components. When rendering these via SSR and hydrating elements, yew panics with
panicked at /home/maa/.cargo/git/checkouts/yew-960e328c77459d96/5bf8abe/packages/yew/src/dom_bundle/position.rs:114:13:
Should not use a trapped DomSlot. Please report this as an internal bug in yew.
Analysis
Although the code relies on a specific ordering, which is not guaranteed to match between server and client, this is not the underlying issue of the panic. Yew renders each hydrating element twice, once to know which DOM element belong to which component and once to "fix up" and run any client side logic that doesn't exist on the server (including the "rendered" callback).
Expected behavior
No panic, or a clear error message about a hydration issue.
Environment:
-
Yew version:
master -
I would like to fix and I have a solution