Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions admin/src/components/TOASTUI/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ class TOIEditor extends React.Component {
this.handleToggle = this.handleToggle.bind(this);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per React method componentWillReceiveProps are considered legacy and advised to avoid them in new code. And that name will continue to work until version 17 only.

@iapain What's your suggestion here ?

componentWillReceiveProps = (nextProps) => {
// It seems that Strapi sets the value property after the editor was initialized,
// this rendering initialValue useless, and proper value never making it into
// the component. Instead, we are setting the value manually, but only on the first
// update.
if (nextProps.value !== this.props.value && this.props.value == null) {
const editor = this.editorRef.current.getInstance();
editor.setMarkdown(nextProps.value, false);
}
}

componentDidMount() {
const editor = this.editorRef.current.getInstance();
const toolbar = editor.getUI().getToolbar();
Expand Down