1
0

fermi.rs 519 B

1234567891011121314151617181920212223242526272829
  1. #![allow(non_snake_case)]
  2. use dioxus::prelude::*;
  3. fn main() {
  4. dioxus::desktop::launch(app)
  5. }
  6. static NAME: Atom<String> = |_| "world".to_string();
  7. fn app(cx: Scope) -> Element {
  8. let name = use_read(&cx, NAME);
  9. cx.render(rsx! {
  10. div { "hello {name}!" }
  11. Child {}
  12. })
  13. }
  14. fn Child(cx: Scope) -> Element {
  15. let set_name = use_set(&cx, NAME);
  16. cx.render(rsx! {
  17. button {
  18. onclick: move |_| set_name("dioxus".to_string()),
  19. "reset name"
  20. }
  21. })
  22. }