sstur / react-rte

Pure React rich text WYSIWYG editor based on draft-js.
https://react-rte.org
ISC License
2.86k stars 429 forks source link

Usage with React hooks #322

Closed 7s4r closed 5 years ago

7s4r commented 5 years ago

I'm trying to integrate react-rte with react hooks like this:

const Documentation = () => {
  const [editorState, setEditorState] = useState(RichTextEditor.createEmptyValue())

  return (
    <RichTextEditor
       value={editorState}
       onChange={value => setEditorState({ value })}
    />
  )
}

And i'm getting this error:

Uncaught TypeError: n.getEditorState is not a function at e.value (react-rte.js:11)

Are you going to update this package to be compatible with react hooks and globally, will it be maintained?

sstur commented 5 years ago

This line is incorrect in your code:

onChange={value => setEditorState({ value })}

Why are you wrapping the value in an object?