diff --git a/packages/core/src/mutations.rs b/packages/core/src/mutations.rs index 49ec0ef84..551069c45 100644 --- a/packages/core/src/mutations.rs +++ b/packages/core/src/mutations.rs @@ -26,7 +26,7 @@ pub struct Mutations<'a> { /// Any templates encountered while diffing the DOM. /// /// These must be loaded into a cache before applying the edits - pub templates: Vec>, + pub templates: Vec>, /// Any mutations required to patch the renderer to match the layout of the VirtualDom pub edits: Vec>, diff --git a/packages/web/src/lib.rs b/packages/web/src/lib.rs index ee8ed8d18..e208b0591 100644 --- a/packages/web/src/lib.rs +++ b/packages/web/src/lib.rs @@ -198,8 +198,9 @@ pub async fn run_with_props(root: fn(Scope) -> Element, root_prop // todo: we need to split rebuild and initialize into two phases // it's a waste to produce edits just to get the vdom loaded - // we need to save the templates in case hydration fails let templates = dom.rebuild().templates; + websys_dom.load_templates(&templates); + if let Err(err) = websys_dom.rehydrate(&dom) { log::error!( "Rehydration failed {:?}. Rebuild DOM into element from scratch", @@ -209,7 +210,6 @@ pub async fn run_with_props(root: fn(Scope) -> Element, root_prop let edits = dom.rebuild(); - websys_dom.load_templates(&templates); websys_dom.load_templates(&edits.templates); websys_dom.apply_edits(edits.edits); }