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

[2.7] Composition API's inject doesn't work for things provided in the same component #13006

Open
maxbogue opened this issue Apr 20, 2023 · 3 comments

Comments

@maxbogue
Copy link

Version

2.7.14

Reproduction link

codesandbox.io

Steps to reproduce

Using the Composition API, provide a value and then inject it in the same component.

What is expected?

The value will be injected; this is the behavior in the 2.6 @vue/composition-api plugin.

What is actually happening?

This injection key is not found, printing a warning (and breaking the app if it depends on this behavior):

[Vue warn]: injection "Symbol(FooKey)" not found.


It seems this was reported before in #12636 but the fix targeted some lifecycle thing instead of this underlying functionality change. I'm trying to upgrade my company from Vue 2.6 to Vue 2.7 (and hopefully to Vue 3 after that) but little breaking changes like this are making it very difficult.

@maxbogue maxbogue changed the title https://github.com/vuejs/vue/issues/12636 [2.7] Composition API's inject doesn't work for things provided in the same component Apr 20, 2023
@posva
Copy link
Member

posva commented Apr 20, 2023

I think this is by design and the @vue/composition-api lib probably has a bug 😬

@maxbogue
Copy link
Author

May I ask why? I don't understand why you wouldn't be able to access something from the current instance after you provide it. Seems perfectly reasonable, as all the necessary context exists.

This sort of breaking change makes it very difficult to update large applications to newer versions of Vue. I know maybe you don't consider the transition from @vue/composition-api as breaking but that's the reality for apps still stuck on Vue 2.6 that were early adopters of the Composition API.

@CraxGrix
Copy link

Is there any new progress on this issue?

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

3 participants