question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

setEditorState is not a function in defaultKeyCommands.js file

See original GitHub issue

How to happen:

  1. set custom blockStyleFn props;
  2. set block type
RichUtils.toggleBlockType(
     this.state.editorState,
     blockType
)
  1. 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 image

file: draft-js-plugins-editor/lib/Editor/defaultKeyCommands.js image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
lvdangcommented, Aug 13, 2019

@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 })

2reactions
nperichSYKEScommented, Jul 31, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found