Please give a brief summary of your issue:
Multiple annotationChange events fired
Please describe your issue and provide steps to reproduce it:
Everytime I call the loadDocument function on UI, the number of “annotationChanged” events increases when I add an FreeTextAnnotation in a document
Use case: There is a UI.loadDocument function inside a useEffect(), every time I select another document the useEffect runs once and the annotationChanged event should be fired once which happens in the initial document load. But when I load multiple documents one after another, the number of annotationChange events increses by one.
The annotationChanged event is fired every time an annotation is added, modified, or deleted. If a new document has 10 annotations, the event will be fired 10 times.
Since the doc reference changes everytime a new document is uploaded, this will cause the event to be registered again. I’d recommend splitting the 2 functions in 2 useEffect blocks so that annotationChanged doesn’t depend on doc.