I want to reset/flush/something a child component whenever the parent changes, but because nothing about the child specifically depends on the parent (and even when I try injecting something just to force that), it seems that the child is completely independent of the parent. I can imagine many scenarios where that is absolutely desirable, so I support that as the default, but I'd like to find a way to override it when needed. An example, modifying the dx new code (as per my usual 😉 ):
#[component]
fn Blog(id: i32) -> Element {
rsx! {
"Blog post {id}"
Comp {
}
Link {
to: Route::Blog {
id: 1
},
"Go to blog 1"
}
Link {
to: Route::Blog {
id: 2
},
"Go to blog 2"
}
}
}
#[component]
fn Comp() -> Element {
// TODO: want this to reset to false every time blog id changes!
let mut clicked = use_signal(|| false);
rsx! {
div {
onclick: move |_| clicked.set(!clicked()),
if clicked() {
"Yes clicked"
} else {
"Not clicked"
}
}
}
}
If you click on the Not clicked message on a blog page, such that it goes to Yes clicked, thereafter, clicking back and forth between Go to blog 1 and Go to blog 2 does not reset the clicked signal. Understandable and fine, but I'd like to know how I can force it anyway, whenever the parent blog id has changed.
Thank you!