1
0

nest.rs 964 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #![allow(non_snake_case, unused)]
  2. use dioxus::prelude::*;
  3. use dioxus_router::prelude::*;
  4. // ANCHOR: route
  5. #[derive(Routable, Clone)]
  6. // Skipping formatting allows you to indent nests
  7. #[rustfmt::skip]
  8. enum Route {
  9. // Start the /blog nest
  10. #[nest("/blog")]
  11. // You can nest as many times as you want
  12. #[nest("/:id")]
  13. #[route("/post")]
  14. PostId {
  15. // You must include parent dynamic segments in child variants
  16. id: usize,
  17. },
  18. // End nests manually with #[end_nest]
  19. #[end_nest]
  20. #[route("/:id")]
  21. // The absolute route of BlogPost is /blog/:name
  22. BlogPost {
  23. id: usize,
  24. },
  25. // Or nests are ended automatically at the end of the enum
  26. }
  27. #[inline_props]
  28. fn BlogPost(cx: Scope, id: usize) -> Element {
  29. todo!()
  30. }
  31. #[inline_props]
  32. fn PostId(cx: Scope, id: usize) -> Element {
  33. todo!()
  34. }
  35. // ANCHOR_END: route
  36. fn main() {}