Skip to content

Commit

Permalink
Memoize the EditorViewContext value
Browse files Browse the repository at this point in the history
  • Loading branch information
tilgovi committed Jul 28, 2023
1 parent 2d8fc2b commit 118b5a5
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/components/EditorView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,17 @@ export function EditorView({
decorations
);

const contextValue = useMemo(
() => ({
state,
dispatchTransaction,
}),
[state, dispatchTransaction]
);

return (
<LayoutGroup>
<EditorViewContext.Provider
value={{
state,
dispatchTransaction,
}}
>
<EditorViewContext.Provider value={contextValue}>
<NodeViewPositionsContext.Provider
value={{
mount: mountRef.current,
Expand Down

0 comments on commit 118b5a5

Please sign in to comment.