2021-02-07 21:21:38 +00:00
|
|
|
//! An example that shows how to:
|
|
|
|
//! create a scope,
|
|
|
|
//! render a component,
|
|
|
|
//! change some data
|
|
|
|
//! render it again
|
|
|
|
//! consume the diffs and write that to a renderer
|
|
|
|
|
2021-02-07 22:38:17 +00:00
|
|
|
use dioxus_core::{prelude::*, scope::Scope};
|
2021-02-07 21:21:38 +00:00
|
|
|
|
2021-02-07 22:38:17 +00:00
|
|
|
fn main() -> Result<(), ()> {
|
2021-02-07 21:21:38 +00:00
|
|
|
let p1 = Props { name: "bob".into() };
|
|
|
|
|
2021-02-07 22:38:17 +00:00
|
|
|
let mut vdom = VirtualDom::new_with_props(Example, p1);
|
2021-02-12 08:07:35 +00:00
|
|
|
// vdom.progress()?;
|
2021-02-07 22:38:17 +00:00
|
|
|
|
|
|
|
Ok(())
|
2021-02-07 21:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Props {
|
|
|
|
name: String,
|
|
|
|
}
|
|
|
|
impl Properties for Props {
|
2021-02-12 05:29:46 +00:00
|
|
|
fn call(&self, ptr: *const ()) {}
|
|
|
|
|
|
|
|
// fn new() -> Self {
|
|
|
|
// todo!()
|
|
|
|
// }
|
2021-02-07 21:21:38 +00:00
|
|
|
}
|
|
|
|
|
2021-02-12 04:03:01 +00:00
|
|
|
static Example: FC<Props> = |ctx, props| {
|
2021-02-07 21:21:38 +00:00
|
|
|
ctx.view(html! {
|
|
|
|
<div>
|
2021-02-12 05:29:46 +00:00
|
|
|
<h1> "hello world!" </h1>
|
|
|
|
<h1> "hello world!" </h1>
|
|
|
|
<h1> "hello world!" </h1>
|
|
|
|
<h1> "hello world!" </h1>
|
2021-02-07 21:21:38 +00:00
|
|
|
</div>
|
|
|
|
})
|
|
|
|
};
|