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

Vue 2.7: injection "Symbol(pinia)" not found #12636

Closed
kingyue737 opened this issue Jul 8, 2022 · 2 comments
Closed

Vue 2.7: injection "Symbol(pinia)" not found #12636

kingyue737 opened this issue Jul 8, 2022 · 2 comments

Comments

@kingyue737
Copy link

kingyue737 commented Jul 8, 2022

Reproduction

https://stackblitz.com/edit/vitejs-vite-erhcjk

Steps to reproduce the bug

Open the reproduction link and see the terminal of devtool

Expected behavior

Should not throw any error

Actual behavior

[Vue warn] injection "Symbol(pinia)" not found

Additional information

Doesn't meet this issue with Vue 2.6 + @vue/composition-api

@posva posva transferred this issue from vuejs/pinia Jul 8, 2022
@vue-bot vue-bot closed this as completed Jul 8, 2022
@posva posva reopened this Jul 8, 2022
@vuejs vuejs deleted a comment from vue-bot Jul 8, 2022
@posva
Copy link
Member

posva commented Jul 8, 2022

More info about this issue: it turns out that getCurrentInstance() is still set during router.beforeEach() which I don't know if it's expected.
The real problem comes from the inject() function checking on the currentInstance.$parent when the currentInstance is actually the root and therefore gives out undefine

Screenshot 2022-07-08 at 09 55 15
d

So either the currentInstance should be undefined or it should reach out for the $root if there is no $parent but I don't know which one is the good fix so I didn't submit the PR

@lozinsky
Copy link

The real problem comes from the inject() function checking on the currentInstance.$parent when the currentInstance is actually the root and therefore gives out undefined

This causes the issue still reproduces when pinia is used in setup function.

Reproduction: https://stackblitz.com/edit/vitejs-vite-t9sovg

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

4 participants