1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use ;
use crate::;
/// A hook that provides access to the navigator to change the router history.
///
/// > The Routable macro will define a version of this hook with an explicit type.
///
/// ```rust
/// # use dioxus::prelude::*;
/// #[derive(Clone, Routable)]
/// enum Route {
/// #[route("/")]
/// Index {},
/// #[route("/:id")]
/// Dynamic { id: usize },
/// }
///
/// #[component]
/// fn App() -> Element {
/// rsx! {
/// Router::<Route> {}
/// }
/// }
///
/// #[component]
/// fn Index() -> Element {
/// let navigator = use_navigator();
///
/// rsx! {
/// button {
/// onclick: move |_| { navigator.push(Route::Dynamic { id: 1234 }); },
/// "Go to /1234"
/// }
/// }
/// }
///
/// #[component]
/// fn Dynamic(id: usize) -> Element {
/// rsx! {
/// p {
/// "Current ID: {id}"
/// }
/// }
/// }
///
/// # let mut vdom = VirtualDom::new(App);
/// # vdom.rebuild_in_place();
/// ```