inject/getCurrentInstance does not work with createVNode and render
Vue version
3.2.37
Link to minimal reproduction
https://stackblitz.com/edit/vitejs-vite-7xsuzb
Steps to reproduce
From @vue/repl idea, I'm creating 1 live preview editor on 1 other storefront project. But when the code renders using createVNode and render, all values from getCurrentInstance are null. Please suggest me how to solve this problem. Thank you!
What is expected?
inject/getCurrentInstance values from app storefront project
What is actually happening?
inject/getCurrentInstance result is always null
System Info
Browsers
Any additional comments?
No response
using internals in this way is hacky and risks breaking in the future
the reproduction doesn't demonstrate the problem described so I kinda need to guess.
However I think your problem is that you have two projects, with two
node_modules
folders, each containing a copy of the vue package, and both are being included at one point. Assuming one is being built as a library and consumed in the other, you have to:in the library, make sure to externalize vue so it's not bundled with the library
in the consuming app's vite config, add
resolve: { dedupe: ['vue'] }
to make vite get rid of duplicate package sources.
I'm not sure what you are asking.
You should direct support questions to this repo's discussions or our discord server