dioxus/reference/tostring.rs

26 lines
643 B
Rust
Raw Normal View History

2021-07-02 01:30:52 -04:00
use dioxus::prelude::*;
2021-07-16 16:11:25 -04:00
use dioxus::ssr;
2021-09-21 13:42:52 -04:00
pub static Example: FC<()> = |cx, props| {
2021-07-16 16:11:25 -04:00
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);
2021-08-26 22:05:09 -04:00
dom.rebuild();
ssr::render_vdom(&dom, |c| c)
2021-07-16 16:11:25 -04:00
});
2021-07-02 01:30:52 -04:00
cx.render(rsx! {
2021-07-16 16:11:25 -04:00
div { "{as_string}" }
})
};
2021-07-02 01:30:52 -04:00
2021-09-21 13:42:52 -04:00
static SomeApp: FC<()> = |cx, props| {
2021-07-16 16:11:25 -04:00
cx.render(rsx! {
div { style: {background_color: "blue"}
h1 {"Some amazing app or component"}
p {"Things are great"}
2021-07-02 01:30:52 -04:00
}
})
};