Unhandled Rejection (Invariant Violation): invalid RawDraftContentState
matfire opened this issue · comments
matfire commented
Hello,
I'm trying to implement megadraft to write articles. Creating an article works fine, and I can save it by calling
let content = editorStateToJSON(this.state.editorState)
When I save it to my DB, I do it this way
//dummy function call
db.save(JSON.stringify(content))
When I try to load it back into an editor to be able to modify/view the article, I retrieve the editor state by doing
editorStateFromRaw(JSON.parse(string_from_db))
The only thing that I see as plausible is that I initialize my state with editorStateFromRaw(null), but I don't see any other way of doing this.
andrey commented
editorStateToJSON
returns a string, not an object, so you don't need to use JSON.stringify
:)
matfire commented
Thank you! That solved it!