Fix cargo test and a number of little cleanup bugs

This commit is contained in:
Jonathan Kelley committed 2024-01-30 17:33:14 -08:00
1 parent eff1dd6c90
commit 0bd9692e45
49 files changed
+307 -309

No files matched your search

+3 -5
View File
@@ -33,7 +33,7 @@ use crate::utils::use_router_internal::use_router_internal;
///
/// #[component]
/// fn Index() -> Element {
/// let path: Route = use_route(&cx).unwrap();
/// let path: Route = use_route();
/// rsx! {
/// h2 { "Current Path" }
/// p { "{path}" }
@@ -45,14 +45,12 @@ use crate::utils::use_router_internal::use_router_internal;
/// # assert_eq!(dioxus_ssr::render(&vdom), "<h1>App</h1><h2>Current Path</h2><p>/</p>")
/// ```
#[must_use]
pub fn use_route<R: Routable + Clone>() -> Option<R> {
pub fn use_route<R: Routable + Clone>() -> R {
match use_router_internal() {
Some(r) => Some(r.current()),
Some(r) => r.current(),
None => {
#[cfg(debug_assertions)]
panic!("`use_route` must have access to a parent router");
#[allow(unreachable_code)]
None
}
}
}