Manual event listener should show updating state
nirvdrum opened this issue · comments
This is about:
- A typo
- Innaccurate/misleading documentation (e.g. technically incorrect advice)
- Undocumented code
- Outdated documentation
- Other
Problem
The manual event listener docs could benefit from showing a complete or more realistic example. The example creates an empty callback, but I suspect in most cases the event listener will end up updating state of some sort. While updating state is straightforward so it could be viewed as noise, the presence of a state handle changes the dependencies list for use_effect_with_deps
. It would make for a more helpful example if it showed how best to handle a heterogeneous list of dependencies.
Details about the solution you'd like (Optional)
I'd like to see the manual event listener docs to have a more comprehensive example. While I appreciate that what you want to do in that event handler can vary, I think an example showing update to state would give a more accurate impression of what is involved.
Additional context (Optional)
Alternatively, the documentation for use_effect_with_deps
could be enhanced by showing how best to pass a heterogeneous list of dependencies. All of the examples I can find in the rustdoc and Yew examples only pass a single dependency value.
Questionaire (Optional)
- I'd like to write this documentation
- 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
I'm not a fan of documenting this even further to avoid encouraging manual event listeners. Yew's event listeners should be preferred
Alternatively, the documentation for
use_effect_with_deps
could be enhanced by showing how best to pass a heterogeneous list of dependencies. All of the examples I can find in the rustdoc and Yew examples only pass a single dependency value.
You can easily pass a tuple (anything that implements ParitalEq is fine)