2022-06-25 13:27:10 +00:00
|
|
|
use dioxus::prelude::*;
|
2022-09-13 23:22:27 +00:00
|
|
|
use dioxus_web::Config;
|
2022-01-07 05:33:09 +00:00
|
|
|
use web_sys::window;
|
|
|
|
|
|
|
|
fn app(cx: Scope) -> Element {
|
|
|
|
cx.render(rsx! {
|
|
|
|
div {
|
|
|
|
h1 { "thing 1" }
|
|
|
|
}
|
|
|
|
div {
|
|
|
|
h2 { "thing 2"}
|
|
|
|
}
|
|
|
|
div {
|
|
|
|
h2 { "thing 2"}
|
|
|
|
"asd"
|
|
|
|
"asd"
|
2022-09-13 03:01:03 +00:00
|
|
|
Bapp {}
|
2022-01-07 05:33:09 +00:00
|
|
|
}
|
|
|
|
(0..10).map(|f| rsx!{
|
|
|
|
div {
|
|
|
|
"thing {f}"
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-09-30 19:03:06 +00:00
|
|
|
#[allow(non_snake_case)]
|
2022-09-13 03:01:03 +00:00
|
|
|
fn Bapp(cx: Scope) -> Element {
|
2022-01-07 05:33:09 +00:00
|
|
|
cx.render(rsx! {
|
|
|
|
div {
|
|
|
|
h1 { "thing 1" }
|
|
|
|
}
|
|
|
|
div {
|
|
|
|
h2 { "thing 2"}
|
|
|
|
}
|
|
|
|
div {
|
|
|
|
h2 { "thing 2"}
|
|
|
|
"asd"
|
|
|
|
"asd"
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
console_error_panic_hook::set_once();
|
2023-09-12 14:07:57 +00:00
|
|
|
tracing_wasm::set_as_global_default();
|
2022-01-07 05:33:09 +00:00
|
|
|
|
|
|
|
let mut dom = VirtualDom::new(app);
|
|
|
|
let _ = dom.rebuild();
|
|
|
|
|
2022-12-07 21:39:22 +00:00
|
|
|
let pre = dioxus_ssr::pre_render(&dom);
|
2023-09-06 22:47:33 +00:00
|
|
|
tracing::trace!("{}", pre);
|
2022-01-07 05:33:09 +00:00
|
|
|
|
|
|
|
// set the inner content of main to the pre-rendered content
|
|
|
|
window()
|
|
|
|
.unwrap()
|
|
|
|
.document()
|
|
|
|
.unwrap()
|
|
|
|
.get_element_by_id("main")
|
|
|
|
.unwrap()
|
|
|
|
.set_inner_html(&pre);
|
|
|
|
|
|
|
|
// now rehydtrate
|
2022-09-13 23:22:27 +00:00
|
|
|
dioxus_web::launch_with_props(app, (), Config::new().hydrate(true));
|
2022-01-07 05:33:09 +00:00
|
|
|
}
|