@kayelaa/canvas API - v0.2.15
    Preparing search index...

    Variable useExportsConst

    useExports: <T extends FC<any, any>>(
        _fc: T,
        onExport: () => KaylaExports<Exports>,
    ) => void = ...

    Exposes a public API (methods, getters, state handles…) to parent components via exportsRef.

    This hook MUST be called at the top level of a component function — never inside loops, conditions, nested functions, or callbacks. The call order of all hooks is strictly fixed across every refresh; reordering calls will corrupt internal state.

    Only one useExports per component — later calls override earlier ones. The exporter function runs on every refresh.

    Type Declaration

    useExports(Player, () => ({
    takeDamage: (amount: number) => { health -= amount; },
    getHealth: () => health,
    rect: useRect() // or exportsRef.current?.rect
    }));

    // Parent usage
    <Player exportsRef={enemyRef} />
    enemyRef.current?.takeDamage(25);