listener.rs 636 B

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