Hi,
We are importing XML from our API on a button click, but our state is not updating and displaying previous XML.
How can we resolve this issue.
Below is the portion of code:
Here,
XML is a state variable,which we are getting from our API,calling on a button click and
path is the pdf URL,which too getting from API call.
Issue is, when we are switching from file1 to file2,we are setting our XML state variable to null,but still XMLof file1 are importing to file2,but our XML value on consoling is displaying NULL.
useEffect(() => {
if (xml) {
if (typeof window !== "undefined") {
if (inst.current) {
if (path) inst.current.loadDocument (path);
inst.current.Core.documentViewer.addEventListener("document Loaded", async () => {
if (xml) {
inst.current.Core.annotationManager.importAnnotations (xml);
}
inst.current.UI.openElements(["notesPanel"]);
}
} else {
if (typeof window !== "undefined") {
if (inst.current)
if (path) inst.current.loadDocument(path);
}
[path, xml]);
Below is our UI:
THis is file1,where annotations(XML)should load.
Below is file2,where annotations(XML) should not load.