Skip to main content

useEntity

@3dverse/livelink-react v0.2.32


@3dverse/livelink-react / useEntity

Function: useEntity()

useEntity(entityProvider, watchedComponents): object

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

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

Parameters

entityProvider

The entity provider.

watchedComponents

keyof ComponentsRecord[] | "any"

Returns

object

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

isPending

isPending: boolean

entity

entity: Entity | 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>;