1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-07-31 12:30:11 +02: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:
喵喵喵
2020-04-27 03:19:25 +08:00
committed by GitHub
parent 67c4b3b330
commit cc57894f98

View File

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