ImFusion Web SDK

useAnnotations

ts
function useAnnotations(data?: Data): HandleArray<Annotation>;

Returns a reactive list of annotations, optionally filtered by dataset.

Subscribes to AnnotationModel.onAnnotationAdded, AnnotationModel.onAnnotationAboutToBeRemoved, and AnnotationModel.onAnnotationEvent.

When data is provided, only annotations belonging to that dataset are returned.

Parameters

ParameterTypeDescription
data?DataOptional dataset to filter annotations by

Returns

HandleArray<Annotation>

A HandleArray of annotations

Throws

If called outside of an ImFusionProvider

Throws

If called before the SDK has finished initializing

Examples

tsx
function AnnotationList() {
  const annotations = useAnnotations();
  return <p>Total annotations: {annotations.length}</p>;
}
tsx
function DataAnnotations({ data }: { data: Data }) {
  const annotations = useAnnotations(data);
  return (
    <p>
      Annotations on {data.name}: {annotations.length}
    </p>
  );
}

On this page