Skip to content

Commit d487078

Browse files
chore(lint): enforce react/memo-dependencies (#25117)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent f88b33a commit d487078

9 files changed

Lines changed: 14 additions & 19 deletions

File tree

‎apps/mobile/src/components/ui/AndroidAnchoredMenu.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
125125
const maxHeight = Math.min(opensDown ? spaceBelow : spaceAbove, 480);
126126
const placeable = local !== null && rootHeight !== null;
127127

128+
const { onPressAction } = props;
128129
const onPressItem = useCallback(
129130
(action: MenuAction) => {
130131
if ((action.subactions?.length ?? 0) > 0) {
@@ -133,12 +134,12 @@ export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
133134
}
134135
close();
135136
if (action.id !== undefined) {
136-
props.onPressAction?.({
137+
onPressAction?.({
137138
nativeEvent: { event: action.id },
138139
} as Parameters<NonNullable<MenuComponentProps["onPressAction"]>>[0]);
139140
}
140141
},
141-
[close, props.onPressAction],
142+
[close, onPressAction],
142143
);
143144

144145
return (

‎apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export function HardwareKeyboardCommandProvider({
119119
if (pathname.split("/")[4] !== "terminal") commands.add("copyThreadReference");
120120
}
121121
return [...commands];
122+
// oxlint-disable-next-line react/memo-dependencies -- registrationVersion invalidates the snapshot of the external keyboard-command registry.
122123
}, [activeThreadRef, pathname, registrationVersion, navigation]);
123124

124125
const onCommand = useCallback(

‎apps/mobile/src/features/settings/scheduled-task-editor.tsx‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function useScheduledTaskEditor() {
7777
[defaultEditor],
7878
);
7979
const startEditor = startScheduledTaskEditor;
80-
const resetEditor = useCallback(() => startEditor(defaultEditor), [defaultEditor, startEditor]);
80+
const resetEditor = useCallback(() => startEditor(defaultEditor), [defaultEditor]);
8181
const readEditor = useCallback(
8282
() => readScheduledTaskEditor(voiceOwnerKey, defaultEditor),
8383
[defaultEditor, voiceOwnerKey],
@@ -93,15 +93,6 @@ export function useScheduledTaskEditor() {
9393
resetEditor,
9494
draftForEnvironment,
9595
}),
96-
[
97-
editor,
98-
voiceOwnerKey,
99-
readEditor,
100-
setEditor,
101-
startEditor,
102-
hasChanges,
103-
resetEditor,
104-
draftForEnvironment,
105-
],
96+
[editor, voiceOwnerKey, readEditor, setEditor, hasChanges, resetEditor, draftForEnvironment],
10697
);
10798
}

‎apps/mobile/src/features/threads/ThreadArrangementSheet.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ function DragHandle(props: {
115115
.onUpdate((event) => latest.current.onMove(event.translationY))
116116
.onEnd((event) => latest.current.onMove(event.translationY))
117117
.onFinalize((_, success) => latest.current.onEnd(!success)),
118-
[props.disabled],
118+
[props.disabled, latest],
119119
);
120120
return (
121121
<GestureDetector gesture={gesture}>

‎apps/mobile/src/features/threads/ThreadFeed.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ function MessageAttachmentFile(props: {
596596
openingRef.current?.abort();
597597
openingRef.current = null;
598598
};
599+
// oxlint-disable-next-line react/memo-dependencies -- Changing the attachment or connection cancels the previous file open even while this screen stays focused.
599600
}, [props.environmentId, attachment.id, httpBaseUrl]),
600601
);
601602

‎apps/mobile/src/features/threads/thread-list-v2-items.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
731731
});
732732
const snoozePresets = useMemo(
733733
() => (swipeActions.secondary === "snooze" ? resolveSnoozePresets(new Date()) : ([] as const)),
734+
// oxlint-disable-next-line react/memo-dependencies -- The minute tick refreshes relative snooze times while the row remains mounted.
734735
[props.snoozePresetMinute, swipeActions.secondary],
735736
);
736737
const snoozePresetActions = useMemo<MenuAction[]>(
@@ -777,7 +778,6 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
777778
props.reorderSupported,
778779
props.pinningSupported,
779780
thread.pinnedAt,
780-
variant,
781781
],
782782
);
783783
const autoSettleMenuItems = useMemo<MenuAction[]>(

‎apps/mobile/src/native/T3ComposerEditor.ios.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export function ComposerEditor({
194194
};
195195
}),
196196
);
197-
}, [props.value, props.context, skillLabels, theme, chipTextColor]);
197+
}, [props.value, props.context, skillLabels, theme, chipTextColor, confirmedTokensRef]);
198198
// Every render resolves against the snapshot history, so a render whose
199199
// (value, selection) lags the acknowledged native state is stamped behind
200200
// the native revision and rejected by the editor instead of re-applying a
@@ -254,7 +254,7 @@ export function ComposerEditor({
254254
});
255255
return acknowledgedEventCount;
256256
},
257-
[],
257+
[nativeEventSnapshotsRef],
258258
);
259259
const themeJson = JSON.stringify(createNativeComposerTheme(theme));
260260
const resolvedTextStyle = StyleSheet.flatten(textStyle) ?? {};

‎apps/mobile/src/native/T3ComposerEditor.native.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export function ComposerEditor({
192192
};
193193
}),
194194
);
195-
}, [props.value, props.context, skillLabels, theme, chipTextColor]);
195+
}, [props.value, props.context, skillLabels, theme, chipTextColor, confirmedTokensRef]);
196196
// Every render resolves against the snapshot history, so a render whose
197197
// (value, selection) lags the acknowledged native state is stamped behind
198198
// the native revision and rejected by the editor instead of re-applying a
@@ -252,7 +252,7 @@ export function ComposerEditor({
252252
});
253253
return acknowledgedEventCount;
254254
},
255-
[],
255+
[nativeEventSnapshotsRef],
256256
);
257257
const { systemColorsActive } = useAppearancePreferences();
258258
const themeJson = JSON.stringify({

‎vite.config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ export default defineConfig({
226226
"unicorn/no-array-reverse": "off",
227227
"react/no-object-type-as-default-prop": "off",
228228
"react/jsx-no-constructed-context-values": "off",
229+
"react/memo-dependencies": "error",
229230
"react/immutability": "error",
230231
"react/no-array-index-key": "error",
231232
"react/no-unstable-nested-components": "error",

0 commit comments

Comments
 (0)