Fixed an "Uncaught ReferenceError" inside of the @astrojs/vue package#12116
Fixed an "Uncaught ReferenceError" inside of the @astrojs/vue package#12116martrapp merged 7 commits intowithastro:mainfrom
Conversation
…ipt by assigning the 'appInstance' reference to it so that it is available for the later established 'astro:unmount' event listener
🦋 Changeset detectedLatest commit: becc89d 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 |
|
@johannesspohr: Could you please take a look, Johannes? |
|
Looks like the same issue is happening for svelte: #12102 |
|
Thanks for bringing this up. It looks to me like we should move attaching the event listener inside the block where |
martrapp
left a comment
There was a problem hiding this comment.
Hi @sammibajrami, the suggested solution would be to revert the file and only move the addEventlistener from line 52 up to line 47 at the end of the if-block. That would restore the logic as it was before the last fix and ensure that app is always defined when referenced.
…nt' event listener to inside of the 'if' statement where the 'app' variable is initialized
|
Not a problem, and thank you too for pointing me in the right direction! |
Changes
I was getting an error on page transitions after upgrading all astro related packages in my project:
Uncaught ReferenceError: app is not definedThe
appreference in question was in the client.js script, and it turned out that it was initiated inside of an if statement that didn't run on transitions.I am making this pull request in the hope that it'll help.
I'm not very familiar with the Astro codebase so if my solution isn't really a solution then feel free to reject the request or to change it or to point me in the right direction to actually solve it myself :)
Testing
Ran the code, the error was gone and no new one took it's place.
Docs
Shouldn't affect a user’s behavior in any way.