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
| Parameter | Type | Description |
|---|---|---|
data? | Data | Optional dataset to filter annotations by |
Returns
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>
);
}