Subscribe on changes!

multipe createApp will change inject value

avatar
Jul 7th 2021

This is expected, it's even used at https://github.com/vueuse/vueuse/blob/main/packages/core/createGlobalState/index.ts) until effectScope() is released.

You need to move any provide/inject inside setup() before any createApp call. You shouldn't call createApp() inside of a Vue component either

BTW your reproduction is very far from minimal and it's difficult to navigate

avatar
Jul 8th 2021

@posva sorry, I change new reproduction. can you review this issue again? thank you very much

avatar
Jul 8th 2021

Yeah, thanks! So, it's what I said before: the inject should happen before the createApp()

avatar
Jul 8th 2021

This is not friendly for user, and we have no way to judge whether there is a createApp before inject

avatar
Jul 8th 2021

I cannot give some warning.

avatar
Jul 10th 2021

@userquin thanks. I know we should use createApp after inject.

But If we develop some components for everyone. Our compoennts cannot give warning to user.

Maybe we can give tips you cannot use xxx after inject at doc. But user donot know useRouter useStore ...... was implemented by inject.