nested.rs 928 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #![allow(unused)]
  2. //! Example of components in
  3. use std::{borrow::Borrow, marker::PhantomData};
  4. use dioxus_core::prelude::*;
  5. fn main() {}
  6. static Header: FC<()> = |ctx| {
  7. let inner = use_ref(&ctx, || 0);
  8. let handler1 = move || println!("Value is {}", inner.borrow());
  9. ctx.render(dioxus::prelude::LazyNodes::new(|nodectx| {
  10. builder::ElementBuilder::new(nodectx, "div")
  11. .child(VNode::Component(nodectx.bump().alloc(VComponent::new(
  12. nodectx,
  13. Bottom,
  14. (),
  15. None,
  16. ))))
  17. .finish()
  18. }))
  19. };
  20. static Bottom: FC<()> = |ctx| {
  21. ctx.render(html! {
  22. <div>
  23. <h1> "bruh 1" </h1>
  24. <h1> "bruh 2" </h1>
  25. </div>
  26. })
  27. };
  28. fn Top(ctx: Context<()>) -> VNode {
  29. ctx.render(html! {
  30. <div>
  31. <h1> "bruh 1" </h1>
  32. <h1> "bruh 2" </h1>
  33. </div>
  34. })
  35. }