rename generic navigator to navigator

This commit is contained in:
Evan Almloff committed 2023-07-26 11:09:40 -07:00
1 parent 947a153347
commit cc94711d62
2 files changed
+5 -5

No files matched your search

+2 -2
View File
@@ -2,9 +2,9 @@ use crate::prelude::{ExternalNavigationFailure, IntoRoutable, RouterContext};
/// A view into the navigation state of a router. /// A view into the navigation state of a router.
#[derive(Clone)] #[derive(Clone)]
pub struct GenericNavigator(pub(crate) RouterContext); pub struct Navigator(pub(crate) RouterContext);
impl GenericNavigator { impl Navigator {
/// Check whether there is a previous page to navigate back to. /// Check whether there is a previous page to navigate back to.
#[must_use] #[must_use]
pub fn can_go_back(&self) -> bool { pub fn can_go_back(&self) -> bool {
+3 -3
View File
@@ -1,6 +1,6 @@
use dioxus::prelude::ScopeState; use dioxus::prelude::ScopeState;
use crate::prelude::{GenericNavigator, RouterContext}; use crate::prelude::{Navigator, RouterContext};
/// A hook that provides access to the navigator to change the router history. Unlike [`use_router`], this hook will not cause a rerender when the current route changes /// A hook that provides access to the navigator to change the router history. Unlike [`use_router`], this hook will not cause a rerender when the current route changes
/// ///
@@ -47,12 +47,12 @@ use crate::prelude::{GenericNavigator, RouterContext};
/// # let mut vdom = VirtualDom::new(App); /// # let mut vdom = VirtualDom::new(App);
/// # let _ = vdom.rebuild(); /// # let _ = vdom.rebuild();
/// ``` /// ```
pub fn use_navigator(cx: &ScopeState) -> &GenericNavigator { pub fn use_navigator(cx: &ScopeState) -> &Navigator {
&*cx.use_hook(|| { &*cx.use_hook(|| {
let router = cx let router = cx
.consume_context::<RouterContext>() .consume_context::<RouterContext>()
.expect("Must be called in a descendant of a Router component"); .expect("Must be called in a descendant of a Router component");
GenericNavigator(router) Navigator(router)
}) })
} }