-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editor.destroy() #919
Comments
Make sure you call |
Although I got this when I try to debug the editor variable. |
Maybe editor is already destroyed? |
No. |
Ok we will test it. |
if (editor.length != 0) {
editor.destroy();
} Looks like editor is an Array. Try |
any update on this issue? I have the same problem, every time I try to destroy the editor instance, it keeps saying that the destroy is not a function. |
you can use it inside |
For anyone getting this error, editor can not be destroyed while it is loading! |
any updates on this matter? I have a TypeError when running
|
getting this now with read only mode |
I am facing the same issue but i will come up with some solution try this `"use client"; interface UpdateEditorProps{ const Editor = ({ editorRef , initialData}:UpdateEditorProps) => {
} export default Editor; |
I ran into this issue. The reason it's rendering twice is because React runs lifecycle functions like This component only renders the editor once and only destroys it if it has the import { Box } from "@chakra-ui/react";
import { useEffect, useRef } from "react";
import EditorJS from "@editorjs/editorjs";
import colors from "tailwindcss/colors";
export default function MarkdownEditor() {
const editorRef = useRef<HTMLDivElement>(null)
const editorInstance = useRef<EditorJS | null>(null);
useEffect(() => {
if (!editorRef.current || editorInstance.current) {
return
}
editorInstance.current = new EditorJS({
holder: editorRef.current,
})
return () => {
if (editorInstance.current?.destroy) {
editorInstance.current.destroy()
}
}
}, [editorRef.current]);
return (
<Box>
<Box ref={ editorRef }></Box>
</Box>
)
} |
I want to destroy the editor instance manually and then set it again when the component is updated.
I am using ReactJs but I am not using the react wrapper.
Whenever I try to call the destroy function I got the error that destroy is not a function.
The text was updated successfully, but these errors were encountered: