The example here uses Callback::from. Use a normal callback if the target route can be the same as the route the component is in, or just to play safe.
What is a "normal" Callback in this context? The quoted wording of the Caution suggests that it's something different than what's returned from Callback::from. But that's the normal-est Callback I can think of.
The Caution goes on to warn about a panic! that would be caused by a button on a page that goes back to the same page. I understand why the hook would not trigger a re-render in that case, but I don't understand why that would panic. I copy/pasted the code into a quick example, and it worked just fine.
Is this perhaps a vestige of CallbackOnce? That's the only thing I can imagine that would cause a panic, if you tried to call a FnOnce twice.
Details about the solution you'd like(Optional)
If this is out of date, and the caveat no longer applies, just removing the Caution should be sufficient.
If there still is something to watch out for, the wording should more explicitly describe the "good" and "bad" option and why the "bad" one will panic, ideally with example code that can be verified to, in fact, panic.
Additional context(Optional)
Questionaire(Optional)
[ ] I'd like to write this documentation
[x] I'd like to write this documentation but I'm not sure what's needed
[ ] I don't have time to add this right now, but maybe later
This is about:
Problem
https://yew.rs/docs/concepts/router#function-components
What is a "normal"
Callback
in this context? The quoted wording of the Caution suggests that it's something different than what's returned fromCallback::from
. But that's the normal-estCallback
I can think of.The Caution goes on to warn about a
panic!
that would be caused by a button on a page that goes back to the same page. I understand why the hook would not trigger a re-render in that case, but I don't understand why that would panic. I copy/pasted the code into a quick example, and it worked just fine.Is this perhaps a vestige of
CallbackOnce
? That's the only thing I can imagine that would cause a panic, if you tried to call aFnOnce
twice.Details about the solution you'd like (Optional)
If this is out of date, and the caveat no longer applies, just removing the Caution should be sufficient.
If there still is something to watch out for, the wording should more explicitly describe the "good" and "bad" option and why the "bad" one will panic, ideally with example code that can be verified to, in fact, panic.
Additional context (Optional)
Questionaire (Optional)