dioxus/packages/core/examples/fc.rs

73 lines
1.3 KiB
Rust
Raw Normal View History

2021-03-09 19:45:52 +00:00
use dioxus_core::component::fc_to_builder;
2021-03-08 02:28:20 +00:00
use dioxus_core::prelude::*;
static BLAH: FC<()> = |ctx| {
2021-03-09 19:45:52 +00:00
let g = "asd".to_string();
2021-03-08 02:28:20 +00:00
ctx.render(rsx! {
div {
SomeComponent {
2021-03-09 19:45:52 +00:00
some_field: g
2021-03-08 02:28:20 +00:00
}
}
})
2021-03-09 19:45:52 +00:00
};
2021-03-08 02:28:20 +00:00
2021-03-09 19:45:52 +00:00
#[derive(PartialEq, Props)]
pub struct ExampleProps {
some_field: String,
2021-03-08 02:28:20 +00:00
}
static SomeComponent: FC<ExampleProps> = |ctx| {
let blah = rsx! {
div {}
};
let data = match 1 {
1 => ctx.render(rsx! (
div {
h1 {}
h3 {}
}
)),
1 => ctx.render(rsx!( div { "abc" } )),
2 => ctx.render(rsx!( div { "abc" } )),
3 => ctx.render(rsx!( div { "abc" } )),
_ => todo!(),
};
let data = match 1 {
1 => ctx.render(rsx! (
div {
h1 {}
h3 {}
}
)),
1 => ctx.render(rsx!(
div { "abc" }
)),
2 => ctx.render(rsx!(
div { "abc" }
)),
3 => ctx.render(rsx!(
div { "abc" }
)),
_ => todo!(),
};
let i = (0..10).map(|v| {
rsx! {
div {
"{v}"
}
}
});
2021-03-09 19:45:52 +00:00
ctx.render(rsx! {
div {
""
}
2021-03-09 19:45:52 +00:00
})
};
2021-03-08 02:28:20 +00:00
fn main() {}