destroy
Release 3.1.0+, Release 2.19.0+
Cleans up resources used by the editor — removes event listeners and references to prevent memory leaks.
Automatically called when the page is unloaded (onBeforeUnload). In single-page applications (SPA), call this when the component is no longer in use (typically on unmount / route change).
Example
// React example — call destroy on unmount
useEffect(() => {
editorInstance = new SynapEditor();
// when leaving the page or unmounting, call destroy
return () => {
if (editorInstance) {
editorInstance.destroy();
editorInstance = null;
}
};
}, []);