Skip to content

Svelte 5: afterUpdate only tracks props that are being used in the template #9420

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

Closed
paoloricciuti opened this issue Nov 13, 2023 · 0 comments · Fixed by #10408
Closed

Svelte 5: afterUpdate only tracks props that are being used in the template #9420

paoloricciuti opened this issue Nov 13, 2023 · 0 comments · Fixed by #10408
Milestone

Comments

@paoloricciuti
Copy link
Member

paoloricciuti commented Nov 13, 2023

Describe the bug

afterUpdate should run every time a component has been updated but currently it only runs if the prop that changes is actually been used in the template.

Reproduction

  • go to this repl
  • update count with the first button
  • observe that the console logs "after update"
  • update count2 with the second button
  • observer that nothing shows up in the console

for reference this is svelte 4 behavior Svelte 4 REPL

Logs

No response

System Info

Svelte REPL

Severity

blocking an upgrade

@benmccann benmccann modified the milestones: 5.x, 5.0 Nov 14, 2023
dummdidumm pushed a commit that referenced this issue Feb 7, 2024
Closes #9420.

This PR creates an $effect.pre (before beforeUpdate and an $effect (for afterUpdate) and, inside those, listen for all locally declared signals plus reactive props. This does mean that we need to link the locally declared signals to the component context (the reverse of the current behaviour, wherein we link the component context to locally declared signals).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants