-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fixed an "Uncaught ReferenceError" inside of the @astrojs/vue package #12116
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Thanks a lot, @sammibajrami!
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 defined
The
app
reference 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.