Skip to content

Commit f635792

Browse files
perf(web): the branch picker compiles without manual memoization
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 7111501 commit f635792

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

‎apps/web/reactCompiledFiles.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,5 @@ export const REACT_COMPILED_FILES = [
9696
"apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx",
9797
"apps/web/src/components/ThreadTerminalDrawer.tsx",
9898
"apps/web/src/components/settings/SettingsPanels.tsx",
99+
"apps/web/src/components/BranchPicker.tsx",
99100
] as const;

‎apps/web/src/components/BranchPicker.tsx‎

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { VcsRef } from "@t3tools/contracts";
22
import { LegendList, type LegendListRef } from "@legendapp/list/react";
33
import {
4-
useCallback,
54
useEffect,
65
useId,
76
useLayoutEffect,
@@ -71,24 +70,21 @@ export function BranchPicker({
7170
const startFromOriginSwitchId = useId();
7271
const branchListScrollElementRef = useRef<HTMLElement | null>(null);
7372
const previousBranchListScrollTopRef = useRef<number | null>(null);
74-
const handleOpenChange = useCallback(
75-
(nextOpen: boolean) => {
76-
previousBranchListScrollTopRef.current = null;
77-
if (!nextOpen) highlightedValueRef.current = null;
78-
onOpenChange(nextOpen);
79-
},
80-
[onOpenChange],
81-
);
73+
const handleOpenChange = (nextOpen: boolean) => {
74+
previousBranchListScrollTopRef.current = null;
75+
if (!nextOpen) highlightedValueRef.current = null;
76+
onOpenChange(nextOpen);
77+
};
8278
const [showTopBranchScrollFade, setShowTopBranchScrollFade] = useState(false);
8379
const [showBottomBranchScrollFade, setShowBottomBranchScrollFade] = useState(false);
84-
const fetchNextBranchPage = useCallback(() => {
80+
const fetchNextBranchPage = () => {
8581
if (!hasNextPage || isFetchingNextPage) {
8682
return;
8783
}
8884

8985
onLoadNext();
90-
}, [onLoadNext, hasNextPage, isFetchingNextPage]);
91-
const maybeFetchNextBranchPage = useCallback(() => {
86+
};
87+
const maybeFetchNextBranchPage = () => {
9288
const scrollElement = branchListScrollElementRef.current;
9389
if (!scrollElement) {
9490
return;
@@ -111,10 +107,10 @@ export function BranchPicker({
111107
}
112108

113109
fetchNextBranchPage();
114-
}, [fetchNextBranchPage, hasNextPage, open, isFetchingNextPage]);
110+
};
115111

116112
const branchListRef = useRef<LegendListRef | null>(null);
117-
const updateBranchListScrollFades = useCallback(() => {
113+
const updateBranchListScrollFades = () => {
118114
const scrollElement = branchListRef.current?.getScrollableNode?.();
119115
if (!(scrollElement instanceof HTMLElement)) {
120116
return;
@@ -123,7 +119,7 @@ export function BranchPicker({
123119
const maxScrollOffset = Math.max(0, scrollElement.scrollHeight - scrollElement.clientHeight);
124120
setShowTopBranchScrollFade(scrollElement.scrollTop > 1);
125121
setShowBottomBranchScrollFade(maxScrollOffset - scrollElement.scrollTop > 1);
126-
}, []);
122+
};
127123

128124
useLayoutEffect(() => {
129125
if (!open) {

0 commit comments

Comments
 (0)