testbed.rs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. use std::cell::Cell;
  2. use dioxus::prelude::*;
  3. use dioxus_core::{
  4. nodes::{VElement, VText},
  5. ElementId,
  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, props| {
  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. button { }
  32. Child {}
  33. })
  34. };
  35. const Child: FC<()> = |cx, props| {
  36. cx.render(rsx!(
  37. h1 {"1" }
  38. h1 {"2" }
  39. h1 {"3" }
  40. h1 {"4" }
  41. ))
  42. };
  43. // this is a bad case that hurts our subtree memoization :(
  44. const AbTest: FC<()> = |cx, props| {
  45. if 1 == 2 {
  46. cx.render(rsx!(
  47. h1 {"1"}
  48. h1 {"2"}
  49. h1 {"3"}
  50. h1 {"4"}
  51. ))
  52. } else {
  53. cx.render(rsx!(
  54. h1 {"1"}
  55. h1 {"2"}
  56. h2 {"basd"}
  57. h1 {"4"}
  58. ))
  59. }
  60. };