Uncaught Error: Unknown DraftEntity key.
See original GitHub issueHello, I have an app with several instances of draft-js where the following code works, except for one where I get the
Uncaught Error: Unknown DraftEntity key.
.
I have:
const entityKey = Entity.create('separator', 'IMMUTABLE', {});
this.props.setEditorState(
AtomicBlockUtils.insertAtomicBlock(
this.props.getEditorState(),
entityKey,
'-'
)
);
I have tried, with the same result:
const editorState = this.props.getEditorState();
const contentState = editorState.getCurrentContent();
const entityKey = contentState.createEntity('separator', 'IMMUTABLE', {});
this.props.setEditorState(
AtomicBlockUtils.insertAtomicBlock(
this.props.getEditorState(),
entityKey,
'-'
)
);
- I have checked that I only have one copy of draft-js in my npm list of packages.
- This is completely unrelated to the use of backspaces. (Other issues with the same error talked about this)
- I have tried adding a whitespace ’ ’ in the key as suggested in other issues, with no luck.
I am not really sure of what does the error mean nor how to debug it so any help is greatly appreciated!
PS: Again, the code works smoothly for the other several instances of draft-js. I can’t really see any differences since I call MyEditor.jsx in the same manner.
FULL STACK TRACE
Uncaught Error: Unknown DraftEntity key. at invariant (bundle.js:10279) at Object.__get (bundle.js:68045) at ContentState.getEntity (bundle.js:67837) at bundle.js:81802 at findRangesImmutable (bundle.js:65705) at ContentBlock.findEntityRanges (bundle.js:65647) at findLinkEntities (bundle.js:81800) at bundle.js:68912 at Array.forEach (<anonymous>) at CompositeDraftDecorator.getDecorations (bundle.js:68900) invariant @ bundle.js:10279 __get @ bundle.js:68045 getEntity @ bundle.js:67837 (anonymous) @ bundle.js:81802 findRangesImmutable @ bundle.js:65705 findEntityRanges @ bundle.js:65647 findLinkEntities @ bundle.js:81800 (anonymous) @ bundle.js:68912 getDecorations @ bundle.js:68900 generate @ bundle.js:84368 (anonymous) @ bundle.js:84216 (anonymous) @ bundle.js:63441 (anonymous) @ bundle.js:63511 (anonymous) @ bundle.js:63257 (anonymous) @ bundle.js:63124 List.__iterate @ bundle.js:62631 OrderedMap.__iterate @ bundle.js:63123 ToKeyedSequence.__iterate @ bundle.js:63255 filterSequence.__iterateUncached @ bundle.js:63508 seqIterate @ bundle.js:61043 Seq.__iterate @ bundle.js:60713 mappedSequence.__iterateUncached @ bundle.js:63440 seqIterate @ bundle.js:61043 Seq.__iterate @ bundle.js:60713 forEach @ bundle.js:64811 (anonymous) @ bundle.js:62386 Map.withMutations @ bundle.js:61778 mergeIntoCollectionWith @ bundle.js:62375 mergeIntoMapWith @ bundle.js:62348 Map.merge @ bundle.js:61729 regenerateTreeForNewBlocks @ bundle.js:84213 (anonymous) @ bundle.js:83846 Map.withMutations @ bundle.js:61778 set @ bundle.js:83816 push @ bundle.js:84087 insertAtomicBlock @ bundle.js:82086 onClick @ bundle.js:91796 (anonymous) @ bundle.js:8631 ReactErrorUtils.invokeGuardedCallback @ bundle.js:15849 executeDispatch @ bundle.js:15634 executeDispatchesInOrder @ bundle.js:15657 executeDispatchesAndRelease @ bundle.js:15313 executeDispatchesAndReleaseTopLevel @ bundle.js:15324 forEachAccumulated @ bundle.js:15948 processEventQueue @ bundle.js:15524 runEventQueueInBatch @ bundle.js:15251 handleTopLevel @ bundle.js:15261 handleTopLevelImpl @ bundle.js:37111 perform @ bundle.js:18775 batchedUpdates @ bundle.js:37029 batchedUpdates @ bundle.js:18232 dispatchEvent @ bundle.js:37186
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:9 (2 by maintainers)
Top GitHub Comments
contentState.createEntity
is not returning an entityKey anymore, instead it returns a contentState.So you have to get the key via this method:
Hello the problem still occurs on production. What is solution? anyone knows?