Trying to serialize & deserialize draft-js EditorState. Couldn't make fromJS create EditorState. sandbox
What I'm trying to achive is to re-create EditorState from serialized javascript object.
Thanks
EditorState maintains undo and redo stacks of ContentState objects. The current ContentState provides, well, the current content:
myContentState = myEditorState.getCurrentContent();
It sounds like what you really want to do is convert the EditorState's current ContentState to raw JS.
This is achieved via the utility function convertToRaw():
myRawJSState = convertToRaw(myContentState);
When it's time to reapply the contents, the companion utility function is convertFromRaw():
myRestorableState = convertFromRaw(JSON.parse(myRawJSState));
Import details and additional info appear on this SO issue.
A detailed example appears at ReactRocket.
Good luck. This isn't easy to parse from the documentation until you know the name of the method you're looking for!