Skip to main content

Declaring Entities

Use the <Entity> component to declare your entities:

<ECS.Provider>
<Entity>
<Transform />
<Health />
</Entity>
</ECS.Provider>
Note

Ensure that entities are declared within the context of an ECS.Provider.

Entity References#

You can pass a React Ref to <Entity> to get a reference:

const CoolSim = () => {
const ref = useRef();
return <Entity ref={ref}>{/* ... */}</Entity>;
};

If you have imperatively created an Entity you can inject it into your <Entity> declaration:

const CoolSim = () => {
const entity = new Entity();
// ...
return <Entity entity={entity}>{/* ... */}</Entity>;
};