getCurrentInstance gets wrong value
Version
3.1.1
Reproduction link
https://codesandbox.io/s/weathered-violet-b01p8
Steps to reproduce
do nothing, you can see the error
What is expected?
currentInstance should be "HelloWorld" component instance, rather than null.
What is actually happening?
currentInstance is null, if you render a component (with setup) in a composition api.
In vue source code, currentInstance is only a variable to cache the instance, before setup is called, the instance was assigned to the currentInstance variable, after the setup called, null was assigned to currentInstance.
If a component A was rendered in a composition api, currentInstance get the wrong value because it have been set to null after the component A rendered. I think it's no right.
Maybe we should use a stack to cache the instance?
You shouldn't call render
manually inside setup()
like that. It looks like you are trynig to use a portal. Your getCurrentInstance()
returns null
after the first manual call of render