mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-27 14:59:27 +08:00
revert: "chore: memoize the editor context value"
This reverts commit e2787e4736
.
This commit is contained in:
parent
48749330ae
commit
d6e4cafef3
@ -1,7 +1,6 @@
|
|||||||
import { Editor } from '@tiptap/core'
|
import { Editor } from '@tiptap/core'
|
||||||
import React, {
|
import React, {
|
||||||
createContext, HTMLAttributes, ReactNode, useContext,
|
createContext, HTMLAttributes, ReactNode, useContext,
|
||||||
useMemo,
|
|
||||||
} from 'react'
|
} from 'react'
|
||||||
|
|
||||||
import { EditorContent } from './EditorContent.js'
|
import { EditorContent } from './EditorContent.js'
|
||||||
@ -38,14 +37,13 @@ export function EditorProvider({
|
|||||||
children, slotAfter, slotBefore, editorContainerProps = {}, ...editorOptions
|
children, slotAfter, slotBefore, editorContainerProps = {}, ...editorOptions
|
||||||
}: EditorProviderProps) {
|
}: EditorProviderProps) {
|
||||||
const editor = useEditor(editorOptions)
|
const editor = useEditor(editorOptions)
|
||||||
const editorContextValue = useMemo(() => ({ editor }), [editor])
|
|
||||||
|
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EditorContext.Provider value={editorContextValue}>
|
<EditorContext.Provider value={{ editor }}>
|
||||||
{slotBefore}
|
{slotBefore}
|
||||||
<EditorConsumer>
|
<EditorConsumer>
|
||||||
{({ editor: currentEditor }) => (
|
{({ editor: currentEditor }) => (
|
||||||
|
Loading…
Reference in New Issue
Block a user