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

    Variable useEffectConst

    useEffect: (onEffect: () => void | (() => void)) => void = ...

    Registers an effect that runs after entity creation and after every refresh.

    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; reordering calls will corrupt effect registration.

    The effect callback runs synchronously after refresh completes. If it returns a function, that cleanup runs before the next effect execution or when the entity is destroyed.

    Multiple useEffect calls stack — all run in declaration order. Effects are re-registered on every refresh (no dependency array in current version).

    Use only for side-effects that need to re-apply on refresh (e.g. re-attach listeners when props/state change). For true one-time initialization that should never re-run (physics setup, audio context, one-shot preload), use useInitialization instead — it runs exactly once on first mount.

    Type Declaration

      • (onEffect: () => void | (() => void)): void
      • Parameters

        • onEffect: () => void | (() => void)

        Returns void

    useInitialization — for one-shot setup that survives refreshes