finish fixing router
This commit is contained in:
1 parent
adf67b4384
commit
ecf17b351c
2 files changed
+1
-5
No files matched your search
@@ -49,13 +49,11 @@ fn NavBar() -> Element {
|
|||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
fn Home() -> Element {
|
fn Home() -> Element {
|
||||||
println!("Home");
|
|
||||||
rsx! { h1 { "Welcome to the Dioxus Blog!" } }
|
rsx! { h1 { "Welcome to the Dioxus Blog!" } }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
fn Blog() -> Element {
|
fn Blog() -> Element {
|
||||||
println!("Blog");
|
|
||||||
rsx! {
|
rsx! {
|
||||||
h1 { "Blog" }
|
h1 { "Blog" }
|
||||||
Outlet::<Route> {}
|
Outlet::<Route> {}
|
||||||
|
|||||||
@@ -12,16 +12,14 @@ use crate::prelude::*;
|
|||||||
/// - Otherwise [`Some`].
|
/// - Otherwise [`Some`].
|
||||||
pub(crate) fn use_router_internal() -> Option<RouterContext> {
|
pub(crate) fn use_router_internal() -> Option<RouterContext> {
|
||||||
let router = use_hook(consume_context::<RouterContext>);
|
let router = use_hook(consume_context::<RouterContext>);
|
||||||
|
let id = current_scope_id().expect("use_router_internal called outside of a component");
|
||||||
use_on_destroy({
|
use_on_destroy({
|
||||||
to_owned![router];
|
to_owned![router];
|
||||||
move || {
|
move || {
|
||||||
let id = current_scope_id().expect("use_router_internal called outside of a component");
|
|
||||||
|
|
||||||
router.unsubscribe(id);
|
router.unsubscribe(id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
use_hook(move || {
|
use_hook(move || {
|
||||||
let id = current_scope_id().expect("use_router_internal called outside of a component");
|
|
||||||
router.subscribe(id);
|
router.subscribe(id);
|
||||||
|
|
||||||
Some(router)
|
Some(router)
|
||||||
|
|||||||
Reference in new issue
Block a user