Skip to content

Commit 18fc403

Browse files
perf(mobile): Home's thread handler survives its parent re-rendering
Called as props.onSelectThread(...), the React Compiler cached the handler on the whole props object, which Home's parent replaces on every render (the connection status flips it every few seconds). Every visible row then re-rendered. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 18bdcdc commit 18fc403

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎apps/mobile/src/features/home/HomeScreen.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,9 @@ export function HomeScreen(props: HomeScreenProps) {
490490
// unchanged: after a clamped fire (wake beyond the 32-bit setTimeout
491491
// range) the boundary string is identical and the chain would die.
492492
}, [nextSnoozeWakeAt, snoozeWakeTick]);
493+
// Called as `props.onSelectThread(...)`, the compiler would cache this handler on the whole
494+
// props object, which is new on every render of Home's parent.
495+
const { onSelectThread } = props;
493496
// A row listed for a message match opens the thread at that message, by
494497
// tap or by shortcut.
495498
const selectThread = (thread: EnvironmentThreadShell) => {
@@ -500,7 +503,7 @@ export function HomeScreen(props: HomeScreenProps) {
500503
if (messageId) {
501504
requestThreadMessageJump(scopedThreadKey(thread.environmentId, thread.id), messageId);
502505
}
503-
props.onSelectThread(thread);
506+
onSelectThread(thread);
504507
};
505508
useThreadJumpShortcuts(threadListV2Items, selectThread);
506509
useEffect(() => {

0 commit comments

Comments
 (0)