component_children_inspect.rs 784 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // ANCHOR: all
  2. #![allow(non_snake_case, unused)]
  3. use dioxus::prelude::*;
  4. fn main() {
  5. dioxus_desktop::launch(App);
  6. }
  7. fn App(cx: Scope) -> Element {
  8. // ANCHOR: Clickable_usage
  9. cx.render(rsx! {
  10. Clickable {
  11. href: "https://www.youtube.com/watch?v=C-M2hs3sXGo",
  12. "How to " i {"not"} " be seen"
  13. }
  14. })
  15. // ANCHOR_END: Clickable_usage
  16. }
  17. #[derive(Props)]
  18. struct ClickableProps<'a> {
  19. href: &'a str,
  20. children: Element<'a>,
  21. }
  22. // ANCHOR: Clickable
  23. fn Clickable<'a>(cx: Scope<'a, ClickableProps<'a>>) -> Element {
  24. match cx.props.children {
  25. Some(VNode::Text(_)) => {
  26. todo!("render some stuff")
  27. }
  28. _ => {
  29. todo!("render some other stuff")
  30. }
  31. }
  32. }
  33. // ANCHOR_END: Clickable