dioxus/packages/atoms/examples/hellorecoil.rs

30 lines
718 B
Rust
Raw Normal View History

2021-05-26 05:40:30 +00:00
use dioxus_core::prelude::*;
use recoil::*;
const COUNT: Atom<i32> = |_| 0;
static App: FC<()> = |ctx| {
2021-05-27 21:57:59 +00:00
use_init_recoil_root(ctx, |_| {});
2021-06-15 14:02:46 +00:00
let (count, set_count) = use_read_write(&ctx, &COUNT);
2021-05-26 05:40:30 +00:00
rsx! { in ctx,
div {
"Count: {count}"
2021-05-31 22:55:56 +00:00
br {}
button { onclick: move |_| set_count(count + 1), "<Incr" }
">___<"
button { onclick: move |_| set_count(count - 1), "Decr>" }
2021-05-26 05:40:30 +00:00
}
}
};
fn main() {
2021-05-31 22:55:56 +00:00
// Setup logging
wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
console_error_panic_hook::set_once();
log::debug!("asd");
wasm_bindgen_futures::spawn_local(dioxus_web::WebsysRenderer::start(App));
2021-05-26 05:40:30 +00:00
}