1
0

component_borrowed_props.rs 492 B

123456789101112131415161718192021222324252627
  1. #![allow(non_snake_case)]
  2. use dioxus::prelude::*;
  3. fn main() {
  4. dioxus_desktop::launch(App);
  5. }
  6. // ANCHOR: App
  7. fn App(cx: Scope) -> Element {
  8. let hello = "Hello Dioxus!";
  9. cx.render(rsx!(TitleCard { title: hello }))
  10. }
  11. // ANCHOR_END: App
  12. // ANCHOR: TitleCard
  13. #[derive(Props)]
  14. struct TitleCardProps<'a> {
  15. title: &'a str,
  16. }
  17. fn TitleCard<'a>(cx: Scope<'a, TitleCardProps<'a>>) -> Element {
  18. cx.render(rsx! {
  19. h1 { "{cx.props.title}" }
  20. })
  21. }
  22. // ANCHOR_END: TitleCard