nested.rs 949 B

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