Function to run asynchronously in the next microtask
function Parent() {
const childrenRef = useRef<KaylaExports<any>[]>([]);
useInitialization(() => {
useNextStack(() => {
// Now children should be mounted & exports available
const kids = getChildrenEntities(); // or however you collect them
childrenRef.current = kids.map(k => k.exportsRef?.current).filter(Boolean);
console.log("Children ready:", childrenRef.current.length);
});
});
return (
<>
<Child exportsRef={child1Ref} />
<Child exportsRef={child2Ref} />
</>
);
}
Schedules a callback to run in the next microtask (after the current call stack clears).
This is not a hook — you can call it anywhere inside a component function, including inside
useTick,useInitialization,useEffect, etc.Most useful when you need to:
exportsRef.current, child entities, or sibling fibers immediately after mount/refresh