1
0

first_route.rs 726 B

1234567891011121314151617181920212223242526272829303132333435
  1. // ANCHOR: router
  2. #![allow(non_snake_case)]
  3. use dioxus::prelude::*;
  4. use dioxus_router::prelude::*;
  5. /// An enum of all of the possible routes in the app.
  6. #[derive(Routable, Clone)]
  7. enum Route {
  8. // The home page is at the / route
  9. #[route("/")]
  10. // If the name of the component and variant are the same you can omit the component and props name
  11. // #[route("/", ComponentName, PropsName)]
  12. Home {},
  13. }
  14. // ANCHOR_END: router
  15. // ANCHOR: app
  16. #[inline_props]
  17. fn App(cx: Scope) -> Element {
  18. render! {
  19. Router {}
  20. }
  21. }
  22. // ANCHOR_END: app
  23. // ANCHOR: home
  24. #[inline_props]
  25. fn Home(cx: Scope) -> Element {
  26. render! {
  27. h1 { "Welcome to the Dioxus Blog!" }
  28. }
  29. }
  30. // ANCHOR_END: home
  31. fn main() {}