|
1 | | -import { use, useCallback, useRef, useState } from "react"; |
| 1 | +import { use, useRef, useState } from "react"; |
2 | 2 |
|
3 | 3 | import { |
4 | 4 | type DraggingStateByNodeId, |
@@ -45,23 +45,20 @@ export const EditorProvider: React.FC<EditorProviderProps> = ({ children }) => { |
45 | 45 | }, 500); |
46 | 46 | }; |
47 | 47 |
|
48 | | - const setSelection = useCallback( |
49 | | - ( |
50 | | - selectionOrUpdater: SelectionMap | ((prev: SelectionMap) => SelectionMap), |
51 | | - ) => |
52 | | - setState((prev) => { |
53 | | - const selection = |
54 | | - typeof selectionOrUpdater === "function" |
55 | | - ? selectionOrUpdater(prev.selection) |
56 | | - : selectionOrUpdater; |
57 | | - const hasSelection = selection.size > 0; |
58 | | - if (prev.hasSelection !== hasSelection) { |
59 | | - triggerPanelAnimation(); |
60 | | - } |
61 | | - return { ...prev, selection, hasSelection }; |
62 | | - }), |
63 | | - [], |
64 | | - ); |
| 48 | + const setSelection = ( |
| 49 | + selectionOrUpdater: SelectionMap | ((prev: SelectionMap) => SelectionMap), |
| 50 | + ) => |
| 51 | + setState((prev) => { |
| 52 | + const selection = |
| 53 | + typeof selectionOrUpdater === "function" |
| 54 | + ? selectionOrUpdater(prev.selection) |
| 55 | + : selectionOrUpdater; |
| 56 | + const hasSelection = selection.size > 0; |
| 57 | + if (prev.hasSelection !== hasSelection) { |
| 58 | + triggerPanelAnimation(); |
| 59 | + } |
| 60 | + return { ...prev, selection, hasSelection }; |
| 61 | + }); |
65 | 62 |
|
66 | 63 | const actions: Omit<EditorActions, "isSelected"> = { |
67 | 64 | setGlobalMode: (mode) => |
@@ -163,10 +160,7 @@ export const EditorProvider: React.FC<EditorProviderProps> = ({ children }) => { |
163 | 160 | }); |
164 | 161 |
|
165 | 162 | const { selection } = state; |
166 | | - const isSelected = useCallback( |
167 | | - (id: string) => selection.has(id), |
168 | | - [selection], |
169 | | - ); |
| 163 | + const isSelected = (id: string) => selection.has(id); |
170 | 164 |
|
171 | 165 | const contextValue: EditorContextValue = { |
172 | 166 | ...state, |
|
0 commit comments