chore: finish tweaking context api
This commit is contained in:
1 parent
99a818996e
commit
df4a1b6c7a
12 files changed
+76
-81
No files matched your search
@@ -1,10 +1,8 @@
|
||||
use crate::RouterService;
|
||||
use dioxus::core::ScopeState;
|
||||
use crate::RouterContext;
|
||||
use dioxus::{core::ScopeState, prelude::use_context};
|
||||
|
||||
/// This hook provides access to the `RouterService` for the app.
|
||||
pub fn use_router(cx: &ScopeState) -> &RouterService {
|
||||
cx.use_hook(|| {
|
||||
cx.consume_context::<RouterService>()
|
||||
.expect("Cannot call use_route outside the scope of a Router component")
|
||||
})
|
||||
pub fn use_router(cx: &ScopeState) -> &RouterContext {
|
||||
use_context::<RouterContext>(cx)
|
||||
.expect("Cannot call use_route outside the scope of a Router component")
|
||||
}
|
||||
Reference in new issue
Block a user