From e2787e4736002dd85e196ef73f602ac901fe6392 Mon Sep 17 00:00:00 2001 From: Nick the Sick Date: Mon, 28 Oct 2024 16:03:31 +0100 Subject: [PATCH] chore: memoize the editor context value --- packages/react/src/Context.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/react/src/Context.tsx b/packages/react/src/Context.tsx index 8c285d837..5677e3973 100644 --- a/packages/react/src/Context.tsx +++ b/packages/react/src/Context.tsx @@ -1,6 +1,7 @@ import { Editor } from '@tiptap/core' import React, { createContext, HTMLAttributes, ReactNode, useContext, + useMemo, } from 'react' import { EditorContent } from './EditorContent.js' @@ -37,13 +38,14 @@ export function EditorProvider({ children, slotAfter, slotBefore, editorContainerProps = {}, ...editorOptions }: EditorProviderProps) { const editor = useEditor(editorOptions) + const editorContextValue = useMemo(() => ({ editor }), [editor]) if (!editor) { return null } return ( - + {slotBefore} {({ editor: currentEditor }) => (