Skip to main content

Function: useEntity()

function useEntity(
entityProvider: EntityProvider,
watchedComponents: keyof ComponentsRecord[] | "any",
): {
isPending: boolean;
entity: Entity | null;
};

Defined in: livelink.react/sources/hooks/useEntity.ts:84

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

Parameters

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

Returns

{
isPending: boolean;
entity: Entity | null;
}

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

NameType
isPendingboolean
entityEntity | null

Example

const { isPending, entity } = useEntity({ id: "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>;