I wrote small dependency container plugin for Vue 2.7. i need use getCurrentInstance.
It works correctly if i import one from Vue directly.
But if i change import from 'vue-demi', i always get error 'Dependency container undefined. Check plugin setup'
import { getCurrentInstance } from 'vue-demi'
import { DescriptorsContainer } from './plugin/descriptors-container'
export function getContainer (): DescriptorsContainer {
const currentInstance = getCurrentInstance()?.proxy
// it is defined and not null if i import getCurrentInstance from Vue directly
const container = currentInstance?.$vueModelerDc
if (!container) {
// i alway here If getCurrentInstance imported from vue-demi
throw new Error('Dependency container undefined. Check plugin setup')
}
return container
}
I wrote small dependency container plugin for Vue 2.7. i need use getCurrentInstance.
It works correctly if i import one from Vue directly. But if i change import from 'vue-demi', i always get error 'Dependency container undefined. Check plugin setup'
please, help me understand what is wrong