TypeScript
perf(web): the branch picker compiles without manual memoization (#20557)
Julius Marminge78c0d7df69e1
diff --git a/apps/web/src/components/BranchPicker.tsx b/apps/web/src/components/BranchPicker.tsxindex 795a5a32994..6ee2a065786 100644--- a/apps/web/src/components/BranchPicker.tsx+++ b/apps/web/src/components/BranchPicker.tsx@@ -1,7 +1,6 @@import type { VcsRef } from "@t3tools/contracts";import { LegendList, type LegendListRef } from "@legendapp/list/react";import {- useCallback,useEffect,useId,useLayoutEffect,@@ -71,24 +70,21 @@ export function BranchPicker({const startFromOriginSwitchId = useId();const branchListScrollElementRef = useRef<HTMLElement | null>(null);const previousBranchListScrollTopRef = useRef<number | null>(null);- const handleOpenChange = useCallback(- (nextOpen: boolean) => {- previousBranchListScrollTopRef.current = null;- if (!nextOpen) highlightedValueRef.current = null;- onOpenChange(nextOpen);- },- [onOpenChange],- );+ const handleOpenChange = (nextOpen: boolean) => {+ previousBranchListScrollTopRef.current = null;+ if (!nextOpen) highlightedValueRef.current = null;+ onOpenChange(nextOpen);+ };const [showTopBranchScrollFade, setShowTopBranchScrollFade] = useState(false);const [showBottomBranchScrollFade, setShowBottomBranchScrollFade] = useState(false);- const fetchNextBranchPage = useCallback(() => {+ const fetchNextBranchPage = () => {if (!hasNextPage || isFetchingNextPage) {return;}onLoadNext();- }, [onLoadNext, hasNextPage, isFetchingNextPage]);- const maybeFetchNextBranchPage = useCallback(() => {+ };+ const maybeFetchNextBranchPage = () => {const scrollElement = branchListScrollElementRef.current;if (!scrollElement) {return;@@ -111,10 +107,10 @@ export function BranchPicker({}fetchNextBranchPage();- }, [fetchNextBranchPage, hasNextPage, open, isFetchingNextPage]);+ };const branchListRef = useRef<LegendListRef | null>(null);- const updateBranchListScrollFades = useCallback(() => {+ const updateBranchListScrollFades = () => {const scrollElement = branchListRef.current?.getScrollableNode?.();if (!(scrollElement instanceof HTMLElement)) {return;@@ -123,7 +119,7 @@ export function BranchPicker({const maxScrollOffset = Math.max(0, scrollElement.scrollHeight - scrollElement.clientHeight);setShowTopBranchScrollFade(scrollElement.scrollTop > 1);setShowBottomBranchScrollFade(maxScrollOffset - scrollElement.scrollTop > 1);- }, []);+ };useLayoutEffect(() => {if (!open) {