dioxus/packages/core/examples/fc.rs

39 lines
730 B
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::*;
2021-03-11 00:42:31 +00:00
static BLAH: FC<()> = |ctx, _props| {
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
}
2021-03-11 00:42:31 +00:00
static SomeComponent: FC<ExampleProps> = |ctx, _props| {
2021-03-09 19:45:52 +00:00
ctx.render(rsx! {
div { }
})
};
2021-03-08 02:28:20 +00:00
fn main() {}
2021-03-09 19:45:52 +00:00
impl Properties for ExampleProps {
type Builder = ExamplePropsBuilder<((),)>;
2021-03-11 17:27:01 +00:00
type StaticOutput = ExampleProps;
2021-03-09 19:45:52 +00:00
fn builder() -> Self::Builder {
ExampleProps::builder()
}
2021-03-11 17:27:01 +00:00
unsafe fn into_static(self) -> Self {
self
}
2021-03-09 19:45:52 +00:00
}