Skip to content

ecsia-monorepo / react/src / useTargets

Function: useTargets()

ts
function useTargets(handle, relation): readonly EntityHandle[];

Defined in: react/src/hooks.ts:65

The current targets of relation on handle — every entity this subject points at, as stable handles (valid React keys). Re-renders ONLY when the pair membership for this (subject, relation) changes: a pair added or removed (explicit, exclusive retarget, or cascade teardown). Values are recomputed from rel.targetsOf at snapshot time — always-current truth, identity-stable when the set is unchanged. Requires the relations runtime on the provider: <WorldProvider world={world} relations={rel}>.

Parameters

ParameterType
handleEntityHandle
relationRelationLike

Returns

readonly EntityHandle[]

MIT licensed · 0.x, unpublished, experimental.