globocom / megadraft

Megadraft is a Rich Text editor built on top of Facebook's Draft.JS featuring a nice default base of components and extensibility

Home Page:http://megadraft.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unhandled Rejection (Invariant Violation): invalid RawDraftContentState

matfire opened this issue · comments

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.

editorStateToJSON returns a string, not an object, so you don't need to use JSON.stringify :)

Thank you! That solved it!