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

Improve explanations of keyed each #1262

Open
sacrosanctic opened this issue Apr 5, 2025 · 1 comment
Open

Improve explanations of keyed each #1262

sacrosanctic opened this issue Apr 5, 2025 · 1 comment

Comments

@sacrosanctic
Copy link
Contributor

sacrosanctic commented Apr 5, 2025

Describe the Problem

Users often are confused by why their {#each} doesn't work. And when they do discover keyed each, they struggle to understand why keyed each fixes their problem.

Proposed Solutions

Notes

  • It should be explicitly mentioned that an unkeyed each is the same as keying the index
  • Add animation/visual to better represent what is happening in the DOM
  • Describe the process as syncing data and DOM
  • Remove the need for a Child component as that splits the relevant code and can act as a distraction
  • Provide a side-by-side comparison
  • Either unify the examples or provide multiple examples that are more cohesive and comparable

Reference

@sacrosanctic
Copy link
Contributor Author

Another proposal is to change the default key from index to the object reference when it is an object. This would be a breaking change and would be delayed until the next major release.

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