Skip to content
TypeScript

chore(lint): enforce react/memo-dependencies (#25117)

Julius Marminged487078f11f8
diff --git a/apps/mobile/src/components/ui/AndroidAnchoredMenu.tsx b/apps/mobile/src/components/ui/AndroidAnchoredMenu.tsx
index 5149beb96de..d4a7ab54041 100644
--- a/apps/mobile/src/components/ui/AndroidAnchoredMenu.tsx
+++ b/apps/mobile/src/components/ui/AndroidAnchoredMenu.tsx
@@ -125,6 +125,7 @@ export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
const maxHeight = Math.min(opensDown ? spaceBelow : spaceAbove, 480);
const placeable = local !== null && rootHeight !== null;
+ const { onPressAction } = props;
const onPressItem = useCallback(
(action: MenuAction) => {
if ((action.subactions?.length ?? 0) > 0) {
@@ -133,12 +134,12 @@ export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
}
close();
if (action.id !== undefined) {
- props.onPressAction?.({
+ onPressAction?.({
nativeEvent: { event: action.id },
} as Parameters<NonNullable<MenuComponentProps["onPressAction"]>>[0]);
}
},
- [close, props.onPressAction],
+ [close, onPressAction],
);
return (
diff --git a/apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx b/apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx
index eeb06c4e2e3..7b62a6af94c 100644
--- a/apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx
+++ b/apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx
@@ -119,6 +119,7 @@ export function HardwareKeyboardCommandProvider({
if (pathname.split("/")[4] !== "terminal") commands.add("copyThreadReference");
}
return [...commands];
+ // oxlint-disable-next-line react/memo-dependencies -- registrationVersion invalidates the snapshot of the external keyboard-command registry.
}, [activeThreadRef, pathname, registrationVersion, navigation]);
const onCommand = useCallback(
diff --git a/apps/mobile/src/features/settings/scheduled-task-editor.tsx b/apps/mobile/src/features/settings/scheduled-task-editor.tsx
index c8ff4102969..b593a039fe3 100644
--- a/apps/mobile/src/features/settings/scheduled-task-editor.tsx
+++ b/apps/mobile/src/features/settings/scheduled-task-editor.tsx
@@ -77,7 +77,7 @@ export function useScheduledTaskEditor() {
[defaultEditor],
);
const startEditor = startScheduledTaskEditor;
- const resetEditor = useCallback(() => startEditor(defaultEditor), [defaultEditor, startEditor]);
+ const resetEditor = useCallback(() => startEditor(defaultEditor), [defaultEditor]);
const readEditor = useCallback(
() => readScheduledTaskEditor(voiceOwnerKey, defaultEditor),
[defaultEditor, voiceOwnerKey],
@@ -93,15 +93,6 @@ export function useScheduledTaskEditor() {
resetEditor,
draftForEnvironment,
}),
- [
- editor,
- voiceOwnerKey,
- readEditor,
- setEditor,
- startEditor,
- hasChanges,
- resetEditor,
- draftForEnvironment,
- ],
+ [editor, voiceOwnerKey, readEditor, setEditor, hasChanges, resetEditor, draftForEnvironment],
);
}
diff --git a/apps/mobile/src/features/threads/ThreadArrangementSheet.tsx b/apps/mobile/src/features/threads/ThreadArrangementSheet.tsx
index ae9806117a1..49980f89ce9 100644
--- a/apps/mobile/src/features/threads/ThreadArrangementSheet.tsx
+++ b/apps/mobile/src/features/threads/ThreadArrangementSheet.tsx
@@ -115,7 +115,7 @@ function DragHandle(props: {
.onUpdate((event) => latest.current.onMove(event.translationY))
.onEnd((event) => latest.current.onMove(event.translationY))
.onFinalize((_, success) => latest.current.onEnd(!success)),
- [props.disabled],
+ [props.disabled, latest],
);
return (
<GestureDetector gesture={gesture}>
diff --git a/apps/mobile/src/features/threads/ThreadFeed.tsx b/apps/mobile/src/features/threads/ThreadFeed.tsx
index e743e6ff23e..20999f5b041 100644
--- a/apps/mobile/src/features/threads/ThreadFeed.tsx
+++ b/apps/mobile/src/features/threads/ThreadFeed.tsx
@@ -596,6 +596,7 @@ function MessageAttachmentFile(props: {
openingRef.current?.abort();
openingRef.current = null;
};
+ // oxlint-disable-next-line react/memo-dependencies -- Changing the attachment or connection cancels the previous file open even while this screen stays focused.
}, [props.environmentId, attachment.id, httpBaseUrl]),
);
diff --git a/apps/mobile/src/features/threads/thread-list-v2-items.tsx b/apps/mobile/src/features/threads/thread-list-v2-items.tsx
index 91576c47299..5d458ede8e0 100644
--- a/apps/mobile/src/features/threads/thread-list-v2-items.tsx
+++ b/apps/mobile/src/features/threads/thread-list-v2-items.tsx
@@ -731,6 +731,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
});
const snoozePresets = useMemo(
() => (swipeActions.secondary === "snooze" ? resolveSnoozePresets(new Date()) : ([] as const)),
+ // oxlint-disable-next-line react/memo-dependencies -- The minute tick refreshes relative snooze times while the row remains mounted.
[props.snoozePresetMinute, swipeActions.secondary],
);
const snoozePresetActions = useMemo<MenuAction[]>(
@@ -777,7 +778,6 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
props.reorderSupported,
props.pinningSupported,
thread.pinnedAt,
- variant,
],
);
const autoSettleMenuItems = useMemo<MenuAction[]>(
diff --git a/apps/mobile/src/native/T3ComposerEditor.ios.tsx b/apps/mobile/src/native/T3ComposerEditor.ios.tsx
index dbab05ecd58..751cb546f5c 100644
--- a/apps/mobile/src/native/T3ComposerEditor.ios.tsx
+++ b/apps/mobile/src/native/T3ComposerEditor.ios.tsx
@@ -194,7 +194,7 @@ export function ComposerEditor({
};
}),
);
- }, [props.value, props.context, skillLabels, theme, chipTextColor]);
+ }, [props.value, props.context, skillLabels, theme, chipTextColor, confirmedTokensRef]);
// Every render resolves against the snapshot history, so a render whose
// (value, selection) lags the acknowledged native state is stamped behind
// the native revision and rejected by the editor instead of re-applying a
@@ -254,7 +254,7 @@ export function ComposerEditor({
});
return acknowledgedEventCount;
},
- [],
+ [nativeEventSnapshotsRef],
);
const themeJson = JSON.stringify(createNativeComposerTheme(theme));
const resolvedTextStyle = StyleSheet.flatten(textStyle) ?? {};
diff --git a/apps/mobile/src/native/T3ComposerEditor.native.tsx b/apps/mobile/src/native/T3ComposerEditor.native.tsx
index a6d6fda3990..b518ea2c831 100644
--- a/apps/mobile/src/native/T3ComposerEditor.native.tsx
+++ b/apps/mobile/src/native/T3ComposerEditor.native.tsx
@@ -192,7 +192,7 @@ export function ComposerEditor({
};
}),
);
- }, [props.value, props.context, skillLabels, theme, chipTextColor]);
+ }, [props.value, props.context, skillLabels, theme, chipTextColor, confirmedTokensRef]);
// Every render resolves against the snapshot history, so a render whose
// (value, selection) lags the acknowledged native state is stamped behind
// the native revision and rejected by the editor instead of re-applying a
@@ -252,7 +252,7 @@ export function ComposerEditor({
});
return acknowledgedEventCount;
},
- [],
+ [nativeEventSnapshotsRef],
);
const { systemColorsActive } = useAppearancePreferences();
const themeJson = JSON.stringify({
diff --git a/vite.config.ts b/vite.config.ts
index 72e55509cfd..d37e8f0d103 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -226,6 +226,7 @@ export default defineConfig({
"unicorn/no-array-reverse": "off",
"react/no-object-type-as-default-prop": "off",
"react/jsx-no-constructed-context-values": "off",
+ "react/memo-dependencies": "error",
"react/immutability": "error",
"react/no-array-index-key": "error",
"react/no-unstable-nested-components": "error",