nested.rs 903 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. Bottom,
  13. (),
  14. None,
  15. ))))
  16. .finish()
  17. }))
  18. };
  19. static Bottom: FC<()> = |ctx| {
  20. ctx.render(html! {
  21. <div>
  22. <h1> "bruh 1" </h1>
  23. <h1> "bruh 2" </h1>
  24. </div>
  25. })
  26. };
  27. fn Top(ctx: Context<()>) -> VNode {
  28. ctx.render(html! {
  29. <div>
  30. <h1> "bruh 1" </h1>
  31. <h1> "bruh 2" </h1>
  32. </div>
  33. })
  34. }