Jungwoo-An / react-editor-js

⚛️📝The unofficial editor-js component for React
https://codesandbox.io/s/react-editor-js-v2-34bfl
MIT License
940 stars 77 forks source link

Error: element with ID «editorjs» is missing. Pass correct holder's ID. #225

Open Ivaneyko opened 1 year ago

Ivaneyko commented 1 year ago

Environment

Code

const EditorInput = forwardRef<any, Props>(({
  label, id = '#', value, onChange, required, error, helperText, margin = 'normal',
  readOnly = false, minHeight = 32
}, ref) => {
  const instanceRef = useRef<any>(null);

  const handleInitialize = useCallback((instance:any) => {
    instanceRef.current = instance;
  }, []);

  const handleChange = async () => {
    const editorData = await instanceRef?.current?.save();

    if ( onChange ) onChange(editorData);
  }

  return (
     <ReactEditorJS
         tools={EDITOR_TOOLS}
         defaultValue={value}
         onInitialize={handleInitialize}
         onChange={handleChange}
         readOnly={readOnly}
         minHeight={minHeight}
         holder="editorjs"
     ><div id="editorjs" /></ReactEditorJS>
  )
});

Describe

Trying with and without custom holder. This happens when you go to the page where it is editor located. When loading a page directly, this does not always happen

image

Aldar0K commented 1 year ago

I have the same problem

steebchen commented 1 year ago

This happens all the time with NextJS

gediminastub commented 1 year ago

This helps: https://stackoverflow.com/questions/67688118/unhandled-rejection-error-element-with-id-editorjs-is-missing-pass-correct

orbachar commented 1 year ago

same issue here without SSR