dioxus/packages/core/examples/nested.rs

43 lines
903 B
Rust
Raw Normal View History

2021-02-12 05:29:46 +00:00
#![allow(unused)]
//! Example of components in
2021-05-26 05:40:30 +00:00
use std::{borrow::Borrow, marker::PhantomData};
2021-02-12 05:29:46 +00:00
use dioxus_core::prelude::*;
fn main() {}
static Header: FC<()> = |ctx| {
2021-06-03 16:02:46 +00:00
let inner = use_ref(&ctx, || 0);
2021-02-12 05:29:46 +00:00
2021-05-26 05:40:30 +00:00
let handler1 = move || println!("Value is {}", inner.borrow());
2021-02-12 05:29:46 +00:00
2021-05-26 05:40:30 +00:00
ctx.render(dioxus::prelude::LazyNodes::new(|nodectx| {
builder::ElementBuilder::new(nodectx, "div")
2021-06-02 15:07:30 +00:00
.child(VNode::Component(nodectx.bump().alloc(VComponent::new(
Bottom,
(),
None,
))))
.finish()
}))
2021-02-12 05:29:46 +00:00
};
static Bottom: FC<()> = |ctx| {
2021-03-01 02:21:17 +00:00
ctx.render(html! {
2021-02-12 05:29:46 +00:00
<div>
<h1> "bruh 1" </h1>
<h1> "bruh 2" </h1>
</div>
})
};
2021-05-26 05:40:30 +00:00
fn Top(ctx: Context<()>) -> VNode {
2021-05-26 05:40:30 +00:00
ctx.render(html! {
<div>
<h1> "bruh 1" </h1>
<h1> "bruh 2" </h1>
</div>
})
}