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