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).
21 lines
414 B
Rust
21 lines
414 B
Rust
use dioxus_core_macro::Props;
|
|
|
|
#[derive(Debug, Props)]
|
|
struct SomeProps {
|
|
a: i32,
|
|
|
|
// automatically do the default (none) and automatically Into<T>
|
|
#[builder(default, setter(strip_option))]
|
|
b: Option<i32>,
|
|
}
|
|
|
|
// have we committed to the trait style yet?
|
|
|
|
fn main() {
|
|
let g: SomeProps = SomeProps::builder().a(10).b(10).build();
|
|
|
|
let r = g.b.unwrap_or_else(|| 10);
|
|
}
|
|
|
|
fn auto_into_some() {}
|