1
0

jackjill.rs 922 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. use dioxus::prelude::bumpalo;
  2. use dioxus::prelude::format_args_f;
  3. use dioxus::prelude::*;
  4. use dioxus_core as dioxus;
  5. use dioxus_core::prelude::html;
  6. use dioxus_web::WebsysRenderer;
  7. fn main() {
  8. pretty_env_logger::init();
  9. log::info!("Hello!");
  10. wasm_bindgen_futures::spawn_local(WebsysRenderer::start(Example))
  11. }
  12. static Example: FC<()> = |ctx, props| {
  13. let (name, set_name) = use_state(&ctx, || "...?");
  14. ctx.view(html! {
  15. <div>
  16. <h1> "Hello, {name}" </h1>
  17. <button onclick={move |_| set_name("jack")}> "jack!" </button>
  18. <button onclick={move |_| set_name("jill")}> "jill!" </button>
  19. </div>
  20. })
  21. };
  22. struct ItemProps {
  23. name: String,
  24. birthdate: String,
  25. }
  26. static Item: FC<ItemProps> = |ctx, ItemProps { name, birthdate }| {
  27. ctx.view(html! {
  28. <div>
  29. <p>"{name}"</p>
  30. <p>"{birthdate}"</p>
  31. </div>
  32. })
  33. };