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

Cannot assign to read only property 'current' of object '#<Object>' #218

Closed roia-cf closed 1 year ago

roia-cf commented 1 year ago

Environment

Describe

After upgrading the versions of the above packages in package.json, when using React's useRef hook to initialize the instance of react-editor-js, this error is being thrown.

It worked before the upgrade, and I can't downgrade now for several reasons.

Is there a fix for that or maybe a workaround?

Code:

import React, { useCallback, useRef } from 'react';
import { createReactEditorJS } from 'react-editor-js';

  const editorJSRef = useRef(null);

  const ReactEditorJS = createReactEditorJS();

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

     <ReactEditorJS
          onReady={handleReady}
          holder={'editorId'}
          tools={editorJSToolsMemo}
          onInitialize={handleInitialize}
          logLevel={'ERROR'}
        />
roia-cf commented 1 year ago

This error occurred because of something with our implementation in the application.

However, we've had this implementation for months but only broke when we upgraded the version of these two editor.js packages mentioned above. Not sure what changed but we fixed it on our side. Closing.