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

Can't set value by value prop #200

Open pisacode opened 2 years ago

pisacode commented 2 years ago

Environment

Describe

When setting value editor throws an error => this._editorJS.render is not a function at ClientEditorCore.<anonymous>

I also tried added via data prop but the value is not passing by that either.

<ReactEditorJS
        tools={EDITOR_JS_TOOLS}
        readOnly={isReadOnly}
        onInitialize={handleInitialize}
        enableReInitialize
        value={editorCore.current ? content : null}
      />
milosglickon commented 2 years ago

Environment

  • react-editor-js version:2.24.3

Describe

When setting value editor throws an error => this._editorJS.render is not a function at ClientEditorCore.<anonymous>

I also tried added via data prop but the value is not passing by that either.

<ReactEditorJS
        tools={EDITOR_JS_TOOLS}
        readOnly={isReadOnly}
        onInitialize={handleInitialize}
        enableReInitialize
        value={editorCore.current ? content : null}
      />

having the same problem. I am unable to update the value once the props are updated

idontreallywolf commented 2 years ago

adding yield this._editorJS.isReady; before calling render has solved the issue πŸ‘€ a possible fix maybe? @Jungwoo-An

render(data) {
    return __awaiter(this, void 0, void 0, function* () {
        yield this._editorJS.isReady;
        yield this._editorJS.render(data);
    });
}
EthanL06 commented 1 year ago

adding yield this._editorJS.isReady; before calling render has solved the issue πŸ‘€ a possible fix maybe? @Jungwoo-An

render(data) {
    return __awaiter(this, void 0, void 0, function* () {
        yield this._editorJS.isReady;
        yield this._editorJS.render(data);
    });
}

Was able to update the value with your fix:

const updateValue = (data) => {
  editorCore.current._editorJS.isReady.then(() => {
      editorCore.current._editorJS.render(data);
  });
}
MaximumQuiet commented 1 year ago

@Jungwoo-An Hi! Do you have time to check this? We need this to make things work :(

MaherAzzabi commented 1 year ago

Any updates on the fix please ? do you have a release date for it ? thanks

orbachar commented 1 year ago

+1

SwapnilSoni1999 commented 1 year ago

Anyone fixed this?