Skip to main content

Function: useEntities()

function useEntities(
entityProvider: EntitiesProvider,
watchedComponents: keyof ComponentsRecord[] | "any",
): {
isPending: boolean;
entities: Entity[];
};

Defined in: livelink.react/sources/hooks/useEntities.ts:60

A hook that provides an entity and a flag indicating if the entity is pending loading.

Parameters

ParameterTypeDefault valueDescription
entityProviderEntitiesProviderundefinedThe entity provider.
watchedComponentskeyof ComponentsRecord[] | "any"[]-

Returns

{
isPending: boolean;
entities: Entity[];
}

The entity and a flag indicating if the entity is pending loading.

NameType
isPendingboolean
entitiesEntity[]

Example

const { isPending, entity } = useEntity({ euid: "00000000-0000-0000-0000-000000000000" });
if (isPending) {
return <div>Loading...</div>;
}
if (!entity) {
return <div>Entity not found</div>;
}
return <div>Entity found: {entity.name}</div>;