inlineprops.rs 1015 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //! Run with `cargo-expand` to see what each one expands to.
  2. //! This file is named `inlineprops.rs`, because there used to be a `#[inline_props]` macro to
  3. //! do this. However, it's now deprecated (and will likely be removed in a future major version),
  4. //! so please use `#[component]` instead!
  5. use dioxus::prelude::*;
  6. #[component]
  7. fn Thing1<T>(cx: Scope, _a: T) -> Element {
  8. cx.render(rsx! { "" })
  9. }
  10. #[component]
  11. fn Thing2(cx: Scope, _a: u32) -> Element<'a> {
  12. cx.render(rsx! { "" })
  13. }
  14. #[component]
  15. fn Thing3<'a, T>(cx: Scope<'a>, _a: &'a T) -> Element<'a> {
  16. cx.render(rsx! { "" })
  17. }
  18. #[component]
  19. fn Thing4<'a>(cx: Scope<'a>, _a: &'a u32) -> Element<'a> {
  20. cx.render(rsx! { "" })
  21. }
  22. fn main() {
  23. dioxus_desktop::launch(App);
  24. }
  25. #[component]
  26. fn App(cx: Scope) -> Element {
  27. let state = use_state(cx, || 1);
  28. cx.render(rsx! {
  29. div {
  30. Thing1 { _a: 1 },
  31. Thing2 { _a: 1 },
  32. Thing3 { _a: state },
  33. Thing4 { _a: state },
  34. }
  35. })
  36. }