[Vuejs]-VueJS Race condition during setup methods

0👍

loadInitial isn’t waited during initial render, this results in race condition.

Asynchronous components with async setup should be wrapped with <suspense>, they cannot work otherwise because setup function returns promise object instead of component instance and needs to be treated in a special way by Vue renderer.

In case top-level component is asynchronous, it needs to be wrapped with another component that contains <suspense>.

Alternatively, the application can be initialized prior to rendering:

await loadInitial();
app.mount(...);

Leave a comment