add must use to several hooks
This commit is contained in:
1 parent
04f83e1e92
commit
3bf6d2d7cf
21 files changed
+25
No files matched your search
@@ -48,6 +48,7 @@ use crate::prelude::{Navigator, RouterContext};
|
||||
/// # let mut vdom = VirtualDom::new(App);
|
||||
/// # let _ = vdom.rebuild();
|
||||
/// ```
|
||||
#[must_use]
|
||||
pub fn use_navigator(cx: &ScopeState) -> &Navigator {
|
||||
&*cx.use_hook(|| {
|
||||
let router = cx
|
||||
|
||||
@@ -46,6 +46,7 @@ use crate::utils::use_router_internal::use_router_internal;
|
||||
/// # let _ = vdom.rebuild();
|
||||
/// # assert_eq!(dioxus_ssr::render(&vdom), "<h1>App</h1><h2>Current Path</h2><p>/</p>")
|
||||
/// ```
|
||||
#[must_use]
|
||||
pub fn use_route<R: Routable + Clone>(cx: &ScopeState) -> Option<R> {
|
||||
match use_router_internal(cx) {
|
||||
Some(r) => Some(r.current()),
|
||||
|
||||
@@ -3,6 +3,7 @@ use dioxus::prelude::ScopeState;
|
||||
use crate::{prelude::RouterContext, utils::use_router_internal::use_router_internal};
|
||||
|
||||
#[deprecated = "prefer the use_navigator or use_route functions"]
|
||||
#[must_use]
|
||||
/// A hook that provides access to information about the router.
|
||||
pub fn use_router(cx: &ScopeState) -> &RouterContext {
|
||||
use_router_internal(cx)
|
||||
|
||||
Reference in new issue
Block a user