Skip to content

Commit c88f30b

Browse files
committed
Fix issue for React compiler
1 parent 3dfb714 commit c88f30b

1 file changed

Lines changed: 16 additions & 22 deletions

File tree

libs/@hashintel/petrinaut/src/state/editor-provider.tsx

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { use, useCallback, useRef, useState } from "react";
1+
import { use, useRef, useState } from "react";
22

33
import {
44
type DraggingStateByNodeId,
@@ -45,23 +45,20 @@ export const EditorProvider: React.FC<EditorProviderProps> = ({ children }) => {
4545
}, 500);
4646
};
4747

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+
});
6562

6663
const actions: Omit<EditorActions, "isSelected"> = {
6764
setGlobalMode: (mode) =>
@@ -163,10 +160,7 @@ export const EditorProvider: React.FC<EditorProviderProps> = ({ children }) => {
163160
});
164161

165162
const { selection } = state;
166-
const isSelected = useCallback(
167-
(id: string) => selection.has(id),
168-
[selection],
169-
);
163+
const isSelected = (id: string) => selection.has(id);
170164

171165
const contextValue: EditorContextValue = {
172166
...state,

0 commit comments

Comments
 (0)