chore: finish tweaking context api

This commit is contained in:
Jonathan Kelley committed 2022-12-05 15:30:49 -08:00
1 parent 99a818996e
commit df4a1b6c7a
12 files changed
+76 -81

No files matched your search

+5 -7
View File
@@ -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")
}