mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-30 16:09:12 +00:00
25 lines
647 B
Rust
25 lines
647 B
Rust
use dioxus::prelude::*;
|
|
use dioxus::ssr;
|
|
|
|
pub static Example: FC<()> = |cx| {
|
|
let as_string = use_state(cx, || {
|
|
// Currently, SSR is only supported for whole VirtualDOMs
|
|
// This is an easy/low hanging fruit to improve upon
|
|
let mut dom = VirtualDom::new(SomeApp);
|
|
dom.rebuild_in_place().unwrap();
|
|
ssr::render_vdom(&dom, |c| c)
|
|
});
|
|
|
|
cx.render(rsx! {
|
|
div { "{as_string}" }
|
|
})
|
|
};
|
|
|
|
static SomeApp: FC<()> = |cx| {
|
|
cx.render(rsx! {
|
|
div { style: {background_color: "blue"}
|
|
h1 {"Some amazing app or component"}
|
|
p {"Things are great"}
|
|
}
|
|
})
|
|
};
|