mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-01-31 12:38:18 +01:00
fix(unmount): add destroyed flag, prevent apply change when component… (#3553)
* fix(unmount): add destroyed flag, prevent apply change when component has been destroyed. * style(format): update format * refactor(unmount): remove destroyed flag, use effect return callback to destroy onchange event * styles(format): format styles Co-authored-by: wangchao <wangchao08@kuaishou.com>
This commit is contained in:
parent
67c4b3b330
commit
cc57894f98
@ -1,4 +1,4 @@
|
||||
import React, { useMemo, useState, useCallback } from 'react'
|
||||
import React, { useMemo, useState, useCallback, useEffect } from 'react'
|
||||
import { Node } from 'slate'
|
||||
|
||||
import { ReactEditor } from '../plugin/react-editor'
|
||||
@ -34,6 +34,12 @@ export const Slate = (props: {
|
||||
|
||||
EDITOR_TO_ON_CHANGE.set(editor, onContextChange)
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
EDITOR_TO_ON_CHANGE.set(editor, () => {})
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<SlateContext.Provider value={context}>
|
||||
<EditorContext.Provider value={editor}>
|
||||
|
Loading…
x
Reference in New Issue
Block a user