reactjseditordraftjs

Draft.js: How to clear editor content onClick?


I've downloaded draft.js-utils, but I just can't find an easy way to clear the editor state of draft.js with useState.

At the moment I have the onClick function having the following, but it doesn't do anything:

 setEditorState(clearEditorContent.EditorState);

How to I use this correctly to return a blank EditorState?


Solution

  • The correct way is:

        setEditorState(clearEditorContent(editorState));