Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manual event listener should show updating state #3211

Open
1 of 8 tasks
nirvdrum opened this issue Apr 3, 2023 · 1 comment
Open
1 of 8 tasks

Manual event listener should show updating state #3211

nirvdrum opened this issue Apr 3, 2023 · 1 comment

Comments

@nirvdrum
Copy link
Contributor

nirvdrum commented Apr 3, 2023

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
@hamza1311
Copy link
Member

hamza1311 commented Aug 5, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants