listener.rs 752 B

123456789101112131415161718192021222324252627282930
  1. #![allow(unused, non_upper_case_globals)]
  2. use dioxus_core::prelude::*;
  3. fn main() {
  4. Some(10)
  5. .map(|f| f * 5)
  6. .map(|f| f / 3)
  7. .map(|f| f * 5)
  8. .map(|f| f / 3);
  9. }
  10. static Example: FC<()> = |ctx| {
  11. let (name, set_name) = use_state(&ctx, || "...?");
  12. ctx.render(rsx!(
  13. div {
  14. h1 { "Hello, {name}" }
  15. // look ma - we can rsx! and html! together
  16. {["jack", "jill"].iter().map(|f| html!(<button onclick={move |_| set_name(f)}> "{f}" </button>))}
  17. }
  18. ))
  19. };
  20. pub fn render<'src, 'a, F: for<'b> FnOnce(&'b NodeCtx<'src>) -> VNode<'src> + 'src + 'a, P>(
  21. ctx: &'a Context<'src, P>,
  22. lazy_nodes: LazyNodes<'src, F>,
  23. ) -> VNode<'src> {
  24. ctx.render(lazy_nodes)
  25. }