Skip to content

useBehaviour

useBehaviour<T>(behaviour, value): void

Defined in: packages/engine/src/components/useBehaviour.ts:20

The one hook a behaviour is built from: adds the trait to the nearest Entity on mount, sets it when the value changes, removes it on unmount. An entity a system destroyed first is left alone. The behaviour is a leaf of its entity in the devtools tree, under the calling component’s name with the value as its props.

Type Parameter
T extends Trait
Parameter Type
behaviour Behaviour<T>
value BehaviourValue<T>

void