Closed ludiguo closed 2 years ago
Can you show me stack trace?
This is a reproducible example https://codesandbox.io/s/jodit-react-event-bug-on-unmount-forked-57mlv1
If you click on unmount jodit button, It will throw an error.
I just upgrade to version 1.3.5 to use onPaste method and now I get this error too.
This error occurs because events related to the JoditEditor component are not remembered when react renders. For that, you can use react's useMemo to fix the issue as follows:
import * as React from 'react
const handleJoditOnBlur = React.useMemo((newContent) => { // Deal with the new content })
const handleJoditOnChange = React.useMemo((newContent) => { // Deal with the new content })
<JoditEditor config={config} value={value} onBlur={handleJoditOnBlur} onChange={handleJoditOnChange} />
Looks like the problem is caused as a result of a bad cleanup.
@xdan issue is introduce on this commit: https://github.com/jodit/jodit-react/commit/7bc5d7e9683ec786c861ddbb9118137df532e582 I'm not sure why but it appears that on the cleanup callback we don't have a reference to the events object anymore.
Fixed in 1.3.6
Is there an error in this installation package, or is it a problem that I haven't configured well in my project? It was good before, and suddenly reported an error