Change context api to panic with nice error message
This commit is contained in:
19 files changed
+96
-69
No files matched your search
@@ -9,7 +9,7 @@ use crate::prelude::{ExternalNavigationFailure, IntoRoutable, RouterContext};
|
||||
/// Panics if there is no router present.
|
||||
pub fn navigator() -> Navigator {
|
||||
Navigator(
|
||||
dioxus_lib::prelude::consume_context::<RouterContext>()
|
||||
dioxus_lib::prelude::try_consume_context::<RouterContext>()
|
||||
.expect("A router must be present to use navigator"),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ impl<R> Clone for OutletContext<R> {
|
||||
|
||||
pub(crate) fn use_outlet_context<R: 'static>() -> OutletContext<R> {
|
||||
use_hook(|| {
|
||||
consume_context().unwrap_or(OutletContext::<R> {
|
||||
try_consume_context().unwrap_or(OutletContext::<R> {
|
||||
current_level: 1,
|
||||
_marker: std::marker::PhantomData,
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user