mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-26 22:20:19 +00:00
feat: enable use_router
This commit is contained in:
parent
0d8e9f5ed4
commit
e24957fc19
1 changed files with 8 additions and 0 deletions
|
@ -104,3 +104,11 @@ impl Drop for UseRouteListener {
|
|||
self.router.router.unsubscribe_onchange(self.scope)
|
||||
}
|
||||
}
|
||||
|
||||
/// 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")
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue