setEditorState is not a function in defaultKeyCommands.js file
See original GitHub issueHow to happen:
- set custom
blockStyleFn
props; - set block type
RichUtils.toggleBlockType(
this.state.editorState,
blockType
)
- press “Backspace” Key Util the editor content is empty
Here is the function call stack when “Backspace” key down:
file: draft-js/lib/editOnKeyDown.js
file: draft-js-plugins-editor/lib/Editor/defaultKeyCommands.js
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
If you get an error saying that 'setEditorState' is not a function ...
If you get an error saying that 'setEditorState' is not a function apparently it get fixed adding a further argument, like:
Read more >DraftJS: nextEditorState.getDirectionMap is not a function
If I call setEditorState inside of the onChange method (instead of 'onChange'), everything works fine. However, when I call it from another ...
Read more >draft-js-plugins-editor | Yarn - Package Manager
If set to false the defaultBlockRenderMap from Draft.js is not used as base for the generated blockRenderMap. ... added the utility function composeDecorators...
Read more >Build rich text editors in React using Draft.js and react-draft ...
In this article, we will be using Draft.js and react-draft-wysiwyg to build a rich text editor and display text we created using the...
Read more >What went wrong? Troubleshooting JavaScript - MDN Web Docs
addeventListener is not a function"; A "Learn More" link that links through ... The name of the JavaScript file, which links through to...
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 FreeTop 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
Top GitHub Comments
@zhang-quan-yi - use the forth parameter for draftjs 0.11.0
Per DraftJS doc:
handleKeyCommand?: (command: string, editorState: EditorState, eventTimeStamp: number) => DraftHandleValue
e.g.
handleKeyCommand: (command, editorState, eventTimeStamp, { setEditorState })
I don’t know anything about draft or draft-plugins code, but maybe it’s related to this change in 0.11?? handleKeyCommand in draft now accepts a third param. But draft-plugins was already using the third place for passing editorState…or something. I haven’t yet worked out what’s going on there, or why.
Also, the draft-plugins typescript types file says that pluginFunctions is the fourth spot in handleKeyCommand, not the third, which the code with the error seems to use??
I’m not really sure if this is connected with the bug, or where to go with it. Just figured I’d drop these links with what little I’ve noticed so far in case anyone else finds it helpful.