Files
dioxus/packages/router/src/hooks/use_router.rs
T
2022-06-25 08:27:10 -05:00

11 lines
340 B
Rust

use crate::RouterService;
use dioxus::core::ScopeState;
/// 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")
})
}