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

getCurrentInstance does not work #267

Open
abratko opened this issue Oct 22, 2024 · 0 comments
Open

getCurrentInstance does not work #267

abratko opened this issue Oct 22, 2024 · 0 comments

Comments

@abratko
Copy link

abratko commented Oct 22, 2024

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
}

please, help me understand what is wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant