js_rs
js_rs
SSolidJS
Created by js_rs on 7/29/2024 in #support
Wait on (async) onMount from Parent before running (sync) onMount from Children?
Hey! Let's assume you have a component that functions as a global store provider to all children. It sits atop all components. Like so:
<StoreContext.Provider value={globalStore}>
{props.children}
</StoreContext.Provider>
<StoreContext.Provider value={globalStore}>
{props.children}
</StoreContext.Provider>
This store provider has some onMount() that runs asynchronously. Another component, which is a child of our StoreProvider component, also has some onMount(), but its not (!) async. Then, unfortunately, the order will commence like so:
StoreProdiver - onMount start
SomeChild - onMount start & finish
StoreProvider - onMount finish
StoreProdiver - onMount start
SomeChild - onMount start & finish
StoreProvider - onMount finish
How can we ensure that the order runs like so:
StoreProdiver - onMount start
StoreProvider - onMount finish
SomeChild - onMount start & finish
StoreProdiver - onMount start
StoreProvider - onMount finish
SomeChild - onMount start & finish
Thank you!
3 replies