hellorecoil.rs 714 B

1234567891011121314151617181920212223242526272829
  1. use dioxus_core::prelude::*;
  2. use recoil::*;
  3. const COUNT: Atom<i32> = |_| 0;
  4. static App: FC<()> = |cx| {
  5. use_init_recoil_root(cx, |_| {});
  6. let (count, set_count) = use_read_write(&cx, &COUNT);
  7. rsx! { in cx,
  8. div {
  9. "Count: {count}"
  10. br {}
  11. button { onclick: move |_| set_count(count + 1), "<Incr" }
  12. ">___<"
  13. button { onclick: move |_| set_count(count - 1), "Decr>" }
  14. }
  15. }
  16. };
  17. fn main() {
  18. // Setup logging
  19. wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
  20. console_error_panic_hook::set_once();
  21. log::debug!("asd");
  22. wasm_bindgen_futures::spawn_local(dioxus_web::WebsysRenderer::start(App));
  23. }