testbed.rs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. use std::cell::Cell;
  2. use dioxus::prelude::*;
  3. use dioxus_core::{
  4. nodes::{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. div {
  23. }
  24. }
  25. "h2"
  26. }
  27. "h3"
  28. }
  29. "h4"
  30. div { "h5" }
  31. Child {}
  32. })
  33. };
  34. const Child: FC<()> = |cx| {
  35. cx.render(rsx!(
  36. h1 {"1" }
  37. h1 {"2" }
  38. h1 {"3" }
  39. h1 {"4" }
  40. ))
  41. };
  42. // this is a bad case that hurts our subtree memoization :(
  43. const AbTest: FC<()> = |cx| {
  44. if 1 == 2 {
  45. cx.render(rsx!(
  46. h1 {"1"}
  47. h1 {"2"}
  48. h1 {"3"}
  49. h1 {"4"}
  50. ))
  51. } else {
  52. cx.render(rsx!(
  53. h1 {"1"}
  54. h1 {"2"}
  55. h2 {"basd"}
  56. h1 {"4"}
  57. ))
  58. }
  59. };