From 71eaafaa004230a67393f26646b4edcc8a6e498a Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Wed, 25 May 2022 14:07:28 -0500 Subject: [PATCH] add example --- examples/hot_reload.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 examples/hot_reload.rs diff --git a/examples/hot_reload.rs b/examples/hot_reload.rs new file mode 100644 index 000000000..d98c42323 --- /dev/null +++ b/examples/hot_reload.rs @@ -0,0 +1,15 @@ +use dioxus::prelude::*; + +fn main() { + dioxus::desktop::launch_with_props(with_hot_reload, app, |b| b); +} + +fn app(cx: Scope) -> Element { + let mut count = use_state(&cx, || 0); + + cx.render(rsx! { + h1 { "High-Five counter: {count}" } + button { onclick: move |_| count += 1, "Up high!" } + button { onclick: move |_| count -= 1, "Down low!" } + }) +}