ecsia-monorepo / react/src / useComponentEffect
Function: useComponentEffect()
ts
function useComponentEffect<C>(
handle,
def,
callback): void;Defined in: react/src/hooks.ts:74
Fire callback on every add/remove/change of def on handle WITHOUT re-rendering this component. The callback receives a frozen ComponentSnapshot copy (undefined on remove/despawn), never the pooled EntityRef core observers hand their handlers — a stashed snapshot is harmless where a stashed ref throws. Events arrive at the observer drain inside update(), once per tick per (entity, component).
Type Parameters
| Type Parameter |
|---|
C extends ComponentDef<Readonly<Record<string, FieldToken>>, string> |
Parameters
| Parameter | Type |
|---|---|
handle | EntityHandle |
def | C |
callback | (snapshot, ctx) => void |
Returns
void