Fix-component-undefined-svelte-v5#12102
Fix-component-undefined-svelte-v5#12102martrapp merged 4 commits intowithastro:nextfrom hermit99:fix-component-undefined-svelte-v5
Conversation
🦋 Changeset detectedLatest commit: ffa87ee The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
martrapp
left a comment
There was a problem hiding this comment.
Hi @hermit99, the suggestion would be to revert the file and only move the addEventlistener from line 44 up to line 42 at the end of the else-block. That would ensure that component is always defined when referenced and would also fix the issue that the listener is currently added too often
Co-authored-by: Martin Trapp <94928215+martrapp@users.noreply.github.com>
|
Thanks @martrapp. Pardon me as I'm new to Astro's code base. Your suggestion makes more sense, and I really appreciate it ❤️ |
|
Thank you very much for taking care! 💜 |
* - fix: 'component is not defined' error when unmount svelte 5 component * added changeset * Moving unmount listener to where the component is defined. * Update .changeset/eighty-ligers-punch.md Co-authored-by: Martin Trapp <94928215+martrapp@users.noreply.github.com> --------- Co-authored-by: Martin Trapp <94928215+martrapp@users.noreply.github.com>
* - fix: 'component is not defined' error when unmount svelte 5 component * added changeset * Moving unmount listener to where the component is defined. * Update .changeset/eighty-ligers-punch.md --------- Co-authored-by: Hermit <70563349+hermit99@users.noreply.github.com>
Changes
Small code enhancement, which is easy to understand.
Console error:
Testing
Defensive code added and tested locally.
Docs