Closed tdekoning closed 2 months ago
Reproduced on vanilla Vue as well:
https://stackblitz.com/edit/vitejs-vite-l2tkb3?file=src%2FApp.vue
+1 have the same issue
This is the intended behavior, it was broken before. See https://github.com/vuejs/core/issues/11602
@posva thanks for the explanation, I wasn't aware of that.
@posva Is there a place in the docs where instructions about how to achieve provide/inject using the app instance can be performed? I tried the following but it didn't work either:
getCurrentInstance().appContext.app.provide('myGlobalKey', 'my-global-value');
yes, that works. I wouldn't do it that way though, I would only use app.provide()
directly after creating the app.
Reproduction
https://stackblitz.com/edit/github-ptqlwv-b7gmky?file=app.vue
Steps to reproduce the bug
Just load up the application and see the difference between the injected value from the store and the directly injected value in the component. The value injected into the store is empty, while the component has the correct value
Expected behavior
I expect provide/inject to work in pinia stores.
Actual behavior
The injected value in the store is empty. Also note the
[Vue warn]: injection "myKey" not found.
warning in the console.Additional information
This is using the @pinia/nuxt package inside of a nuxt 3.12.4 application.
This injection pattern used to work with nuxt 3.11.2 and @pinia/nuxt 0.5.1 and pinia 2.1.7