0

when i populate ContentFromRaw data to editor state i get following error

TypeError: next.editorState.getDecorator is not a function

what is the best way to get from database and save it into database

here is what i doing

 const rawDraftContentState = JSON.stringify(convertToRaw(this.state.editorState.getCurrentContent()))
// convert the raw state back to a useable ContentState object
const contentState = convertFromRaw(JSON.parse(rawDraftContentState))
this.setState({
  editorState: contentState
  })
  • Can you include an example of your code where you invoke `next.editorState.getDecorator`? Please include a [mcve] – tshimkus Feb 11 '19 at 19:34
  • i just doing this on button submit `// the raw state, stringified const rawDraftContentState = JSON.stringify(convertToRaw(this.state.editorState.getCurrentContent())) // convert the raw state back to a useable ContentState object const contentState = convertFromRaw(JSON.parse(rawDraftContentState)) this.setState({ editorState: contentState })` –  Feb 11 '19 at 20:09
  • Thanks, but can you please add that to the question and not a comment? [click here to edit question](https://stackoverflow.com/posts/54637661/edit) – tshimkus Feb 11 '19 at 20:13
  • added to question –  Feb 11 '19 at 20:21

1 Answers1

0

contentState & editorState is 2 different object,

you can not set editorState with a contentState,

Use EditorState.push method to create a new editorState with the contenState you get form DB, and then set new EditorState

link

plat123456789
  • 385
  • 3
  • 12