This commit reverts to the old style of props + FC. The old style is desirable because people comfortable with react can automatically be comfortable with dioxus. It's also nice in that the same props can be used to drive two different components - something the trait version couldn't do. Now, our trait bound forces implementations to have the #[derive(Props)] flag. This will need to implement the Properties trait as well as PartialEq (using ptr::equal for closure fields).
42 lines
821 B
Rust
42 lines
821 B
Rust
use dioxus_core::prelude::*;
|
|
|
|
use dioxus_core_macro::fc;
|
|
|
|
use std::marker::PhantomData;
|
|
// #[derive(PartialEq)]
|
|
// pub struct Example<'a> {
|
|
// b: &'a str,
|
|
// ___p: std::marker::PhantomData<&'a ()>,
|
|
// }
|
|
|
|
// impl<'a> FC for Example<'a> {
|
|
// fn render(ctx: Context<'_>, props: &Example<'a>) -> DomTree {
|
|
// let Example { b, .. } = props;
|
|
// {
|
|
// ctx.render(rsx! {
|
|
// div { "abcd {b}" }
|
|
// })
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// always try to fill in with Default
|
|
|
|
// #[fc]
|
|
fn Example(ctx: Context, a: &str, b: &str, c: &str) -> DomTree {
|
|
ctx.render(rsx! {
|
|
div {
|
|
SomeComponent {
|
|
a: "123"
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
// #[fc]
|
|
fn SomeComponent(ctx: Context, a: &str, b: &str) -> DomTree {
|
|
todo!()
|
|
}
|
|
|
|
fn main() {}
|