2021-05-26 05:40:30 +00:00
|
|
|
use dioxus_core::prelude::*;
|
|
|
|
use recoil::*;
|
|
|
|
|
|
|
|
const COUNT: Atom<i32> = |_| 0;
|
|
|
|
|
2021-06-01 22:33:15 +00:00
|
|
|
static App: FC<()> = |ctx| {
|
2021-05-27 21:57:59 +00:00
|
|
|
use_init_recoil_root(ctx, |_| {});
|
|
|
|
|
|
|
|
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
|
|
|
}
|