testbed.rs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. use std::cell::Cell;
  2. use dioxus::prelude::*;
  3. use dioxus_core::{
  4. nodes::{NodeKey, VElement, VText},
  5. RealDomNode,
  6. };
  7. fn main() {
  8. env_logger::init();
  9. dioxus::desktop::launch(Example, |c| c);
  10. }
  11. const STYLE: &str = r#"
  12. body {background-color: powderblue;}
  13. h1 {color: blue;}
  14. p {color: red;}
  15. "#;
  16. const Example: FC<()> = |cx| {
  17. cx.render(rsx! {
  18. Fragment {
  19. Fragment {
  20. Fragment {
  21. "h1"
  22. }
  23. "h2"
  24. }
  25. "h3"
  26. }
  27. "h4"
  28. div { "h5" }
  29. Child {}
  30. })
  31. };
  32. const Child: FC<()> = |cx| {
  33. cx.render(rsx!(
  34. h1 {"1" }
  35. h1 {"2" }
  36. h1 {"3" }
  37. h1 {"4" }
  38. ))
  39. };
  40. // this is a bad case that hurts our subtree memoization :(
  41. const AbTest: FC<()> = |cx| {
  42. if 1 == 2 {
  43. cx.render(rsx!(
  44. h1 {"1"}
  45. h1 {"2"}
  46. h1 {"3"}
  47. h1 {"4"}
  48. ))
  49. } else {
  50. cx.render(rsx!(
  51. h1 {"1"}
  52. h1 {"2"}
  53. h2 {"basd"}
  54. h1 {"4"}
  55. ))
  56. }
  57. };