use_router.rs 339 B

12345678910
  1. use crate::RouterService;
  2. use dioxus::core::ScopeState;
  3. /// This hook provides access to the `RouterService` for the app.
  4. pub fn use_router(cx: &ScopeState) -> &RouterService {
  5. cx.use_hook(|| {
  6. cx.consume_context::<RouterService>()
  7. .expect("Cannot call use_route outside the scope of a Router component")
  8. })
  9. }