dioxus/packages/core/examples/step.rs
Jonathan Kelley 7158bc3575 Feat: revert FC changes (like the old style).
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).
2021-03-09 00:58:20 -05:00

33 lines
717 B
Rust

use dioxus_core::{component::Properties, prelude::*};
fn main() -> Result<(), ()> {
let p1 = SomeProps { name: "bob".into() };
let mut vdom = VirtualDom::new_with_props(Example, p1);
Ok(())
}
#[derive(Debug, PartialEq, Props)]
struct SomeProps {
name: String,
}
static Example: FC<SomeProps> = |ctx, _props| {
ctx.render(html! {
<div>
<h1> "hello world!" </h1>
<h1> "hello world!" </h1>
<h1> "hello world!" </h1>
<h1> "hello world!" </h1>
</div>
})
};
// toodo: derive this
impl Properties for SomeProps {
type Builder = SomePropsBuilder<((),)>;
fn builder() -> Self::Builder {
SomeProps::builder()
}
}