12345678910111213141516171819202122232425262728293031323334 |
- //! Example: README.md showcase
- //!
- //! The example from the README.md.
- use std::time::Duration;
- use dioxus::prelude::*;
- fn main() {
- dioxus::desktop::launch(App);
- }
- static App: Component<()> = |cx| {
- let mut count = use_state(&cx, || 0);
- cx.push_task(async move {
- tokio::time::sleep(Duration::from_millis(100)).await;
- println!("setting count");
- count += 1;
- // count.set(10);
- // *count += 1;
- // let c = count.get() + 1;
- // count.set(c);
- });
- cx.render(rsx! {
- div {
- h1 { "High-Five counter: {count}" }
- // button {
- // onclick: move |_| count +=1 ,
- // "Click me!"
- // }
- }
- })
- };
|