12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- use std::cell::Cell;
- use dioxus::prelude::*;
- use dioxus_core::{
- nodes::{VElement, VText},
- ElementId,
- };
- fn main() {
- env_logger::init();
- dioxus::desktop::launch(Example, |c| c);
- }
- const STYLE: &str = r#"
- body {background-color: powderblue;}
- h1 {color: blue;}
- p {color: red;}
- "#;
- const Example: FC<()> = |cx, props| {
- cx.render(rsx! {
- Fragment {
- Fragment {
- Fragment {
- "h1"
- div {
- }
- }
- "h2"
- }
- "h3"
- }
- "h4"
- div { "h5" }
- button { }
- Child {}
- })
- };
- const Child: FC<()> = |cx, props| {
- cx.render(rsx!(
- h1 {"1" }
- h1 {"2" }
- h1 {"3" }
- h1 {"4" }
- ))
- };
- // this is a bad case that hurts our subtree memoization :(
- const AbTest: FC<()> = |cx, props| {
- if 1 == 2 {
- cx.render(rsx!(
- h1 {"1"}
- h1 {"2"}
- h1 {"3"}
- h1 {"4"}
- ))
- } else {
- cx.render(rsx!(
- h1 {"1"}
- h1 {"2"}
- h2 {"basd"}
- h1 {"4"}
- ))
- }
- };
|