Jungwoo-An / react-editor-js

โš›๏ธ๐Ÿ“The unofficial editor-js component for React
https://codesandbox.io/s/react-editor-js-v2-34bfl
MIT License
954 stars 77 forks source link

Unable to access state (or any other component variable) inside uploadByFile #174

Closed aiavci closed 2 years ago

aiavci commented 2 years ago

Environment

Describe

State parameters are always undefined in uploadByFile

Sample code

<ReactEditorJS
  onChange={(e: any) => handleChange(e)}
  instanceRef={(instance: any) => {
    return (instanceRef.current = instance);
  }}
  tools={{
    image: {
      class: Image,
      config: {
        uploader: {
          uploadByFile: (f) => {
            // Unable to get state here!
          },
        },
      },
    },
  }}
/>;
Jungwoo-An commented 2 years ago

@aiavci Hi! First of all, thanks for your interest! ๐Ÿ‘‹

Could you provide me reproduce link? (Github, Codesandbox, ...)

Thanks!

aiavci commented 2 years ago

https://codesandbox.io/s/interesting-allen-x42xk

Jungwoo-An commented 2 years ago

@aiavci By default, react-editor-js is uncontrolled component. Therefore, tool initialization only once when mounting for the first time.

If you want workaround, feel free to pull request!

Thanks!

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.