From c23971617036fd6a4b744e732029f6d93ad064f0 Mon Sep 17 00:00:00 2001 From: Jose Quesada Date: Wed, 7 Dec 2022 10:04:54 -0600 Subject: [PATCH] updated the example to work with hydartion --- leptos_dom/examples/hydration-test/src/lib.rs | 23 ++++++------------- .../examples/hydration-test/src/main.rs | 10 ++++---- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/leptos_dom/examples/hydration-test/src/lib.rs b/leptos_dom/examples/hydration-test/src/lib.rs index e0f89ab7e..a082dbaba 100644 --- a/leptos_dom/examples/hydration-test/src/lib.rs +++ b/leptos_dom/examples/hydration-test/src/lib.rs @@ -13,19 +13,10 @@ pub fn App(cx: Scope) -> View { #[component] pub fn ComponentA(cx: Scope) -> View { - let (value, set_value) = create_signal(cx, "".to_string()); - div(cx) - .child( - input(cx) - .attr("type", "text") - .prop("value", (cx, value)) - ) - .child( - p(cx) - .child("Value is: ") - .child((cx, value)) - .child("!") - ) + let (value, set_value) = create_signal(cx, "".to_string()); + div(cx) + .child(input(cx).attr("type", "text").prop("value", (cx, value))) + .child(p(cx).child("Value is: ").child((cx, value)).child("!")) .into_view(cx) } @@ -33,10 +24,10 @@ cfg_if::cfg_if! { if #[cfg(feature = "hydrate")] { use wasm_bindgen::prelude::wasm_bindgen; - #[wasm_bindgen] - pub fn hydrate() { + #[wasm_bindgen(start)] + pub fn start() { console_error_panic_hook::set_once(); - leptos::hydrate(body().unwrap(), move |cx| { + leptos::mount_to_body(move |cx| { view! { cx, } }); } diff --git a/leptos_dom/examples/hydration-test/src/main.rs b/leptos_dom/examples/hydration-test/src/main.rs index f8c50fd92..1ddbbf946 100644 --- a/leptos_dom/examples/hydration-test/src/main.rs +++ b/leptos_dom/examples/hydration-test/src/main.rs @@ -1,11 +1,11 @@ -use actix_web::{web, App, HttpResponse, HttpServer}; use actix_files::Files; -use leptos::*; +use actix_web::{web, App, HttpResponse, HttpServer}; use hydration_test::*; +use leptos::*; #[actix_web::main] async fn main() -> std::io::Result<()> { - HttpServer::new(|| App::new() + HttpServer::new(|| App::new() .service(Files::new("/pkg", "./pkg")) .route("/", web::get().to( || async { @@ -23,7 +23,7 @@ async fn main() -> std::io::Result<()> { format!(r#" - + {html} @@ -35,4 +35,4 @@ async fn main() -> std::io::Result<()> { .bind(("127.0.0.1", 8080))? .run() .await -} \ No newline at end of file +}