Skip to content
This repository was archived by the owner on Jan 30, 2026. It is now read-only.

Commit 01f0bf9

Browse files
authored
fix: improve cleanup logic (#11)
This commit refines the cleanup process in the SuperDocTemplateBuilder component by ensuring that the instance is properly referenced before calling the destroy method. It also resets additional references to prevent memory leaks.
1 parent 09e82ee commit 01f0bf9

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/index.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,12 +496,16 @@ const SuperDocTemplateBuilder = forwardRef<
496496
initSuperDoc();
497497

498498
return () => {
499-
if (superdocRef.current) {
500-
if (typeof superdocRef.current.destroy === "function") {
501-
superdocRef.current.destroy();
502-
}
503-
superdocRef.current = null;
499+
triggerCleanupRef.current = null;
500+
menuTriggerFromRef.current = null;
501+
502+
const instance = superdocRef.current;
503+
504+
if (instance && typeof instance.destroy === "function") {
505+
instance.destroy();
504506
}
507+
508+
superdocRef.current = null;
505509
};
506510
}, [
507511
document?.source,

0 commit comments

Comments
 (0)