Open akiwong-cn opened 4 years ago
I'm experiencing the same crash behavior but in a different environment. It almost never happens in Chrome 87, but always happening in Firefox 83 (both on Mac and Windows).
you can use requestAnimationFrame to fix this error, just put the insertText in requestAnimationFrame callback.
Do you want to request a feature or report a bug?
bug
What's the current behavior?
insertText after addMark or removeMark in a React event handler, the editor will crash
code example: https://codesandbox.io/s/slate-addmark-leggp
Slate: 0.58.1 Browser: Chrome OS: Mac
What's the expected behavior?
It may be caused by addMark function call editor.onChange sync and apply function call it in a microtask. conflict with lazy state update in React synthetic events https://github.com/ianstormtaylor/slate/blob/master/packages/slate/src/create-editor.ts#L109