editorState.getCurrentContent is not a function
See original GitHub issueHi,
I’m trying to get Draft.js to work with Redux and Reselect in my React project. I’m setting the initial editorState in my reducer and then use it in my component.
import { fromJS } from 'immutable';
import { EditorState } from 'draft-js';
import {
RECEIVE_EDITOR_CHANGE,
} from './constants';
const initialState = fromJS({
editorState: EditorState.createEmpty(),
});
function writePageReducer(state = initialState, action) {
switch (action.type) {
case RECEIVE_EDITOR_CHANGE:
return state
.set('editorState', action.editorState);
default:
return state;
}
}
<Editor editorState={this.props.editorState} onChange={this.props.editorChange} />
When I load the page I always get editorState.getCurrentContent is not a function as an error.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
TypeError: editorState.getCurrentContent is not a function
I am trying to console the result from react draft wysiwyg and I am getting editorState.getCurrentContent is not a function.
Read more >draft-js.EditorState.getCurrentContent JavaScript ... - Tabnine
How to use. getCurrentContent. function. in. EditorState ... If the server does not respond with OK, we do not want to clearEditor.
Read more >How to use the draft-js.EditorState.forceSelection function in ...
getCurrentContent () // Retrieve current block const selection = editorState.getSelection() const blockKey = selection.getStartKey() let block = content.
Read more >Building a Rich Text Editor with React and Draft.js, Part 3
componentDidMount : The editor will load an empty EditorState if a note does not exist in our database. If a note does exist...
Read more >draft-js-export-html - Bountysource
editorState.getCurrentContent is not a function $ 0. Created 3 years ago in sstur/draft-js-utils with 3 comments.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can save ContentState in redux store with convertToRaw, convertFromRaw.
In your component:
<Editor editorState={this.state.editorState} ... onChange={this.onChange} />
in your code, if you update
to
That would fix your problem.
As @reme3d2y suggested, you could also use convertFromRaw, if the editorState is coming from the outside