diff --git a/packages/macro-types/src/register.rs b/packages/macro-types/src/register.rs index 0027720..d60e64e 100644 --- a/packages/macro-types/src/register.rs +++ b/packages/macro-types/src/register.rs @@ -46,6 +46,10 @@ where root: web_sys::Element, states: ::AppStates, ) -> ::yew::prelude::AppHandle; + fn hydrate_with_root( + root: web_sys::Element, + states: ::AppStates, + ) -> ::yew::prelude::AppHandle; } pub trait DeclType diff --git a/packages/macro/src/utils/app.rs b/packages/macro/src/utils/app.rs index 2152744..052e58e 100644 --- a/packages/macro/src/utils/app.rs +++ b/packages/macro/src/utils/app.rs @@ -170,6 +170,18 @@ pub fn root(input: DeriveApp) -> TokenStream { } ).render() } + + fn hydrate_with_root( + root: web_sys::Element, + states: <#ident as ::hikari_boot::DeclType>::AppStates + ) -> ::yew::prelude::AppHandle<<#ident as ::hikari_boot::Application>::ClientApp> { + ::yew::Renderer::<<#ident as ::hikari_boot::Application>::ClientApp>::with_root_and_props( + root, + ::hikari_boot::AppContextForClient { + states + } + ).hydrate() + } } } }