I need to define an onMounted
hook after the first await
statement because the hook depends on the awaited value. But this results in a warning:
<code>onMounted is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.
</code>
<code>onMounted is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.
</code>
onMounted is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.
I can’t move onMounted
above the await
statement. One method is to await the value inside the hook itself, but I need this value in other places before the component is mounted (so having duplicate awaits doesn’t seem like a good solution). What is the best way to solve this?