Skip to content

Commit af2e15f

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

2 files changed

Lines changed: 9 additions & 9 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/chat/markdownFindContext.ts",
99100
] as const;
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createContext, useCallback } from "react";
1+
import { createContext } from "react";
22

33
// While find is active, folded content stays mounted (hidden) so its text can be
44
// matched. Nothing opens until the selected match lies inside it.
@@ -9,12 +9,11 @@ export const MarkdownFindContext = createContext(false);
99
* match, like the browser's own find-in-page. `onReveal` must be stable.
1010
*/
1111
export function useFindRevealRef(onReveal: () => void) {
12-
return useCallback(
13-
(element: HTMLElement | null) => {
14-
if (!element) return;
15-
element.addEventListener("beforematch", onReveal);
16-
return () => element.removeEventListener("beforematch", onReveal);
17-
},
18-
[onReveal],
19-
);
12+
// The compiler skips hookless functions; a new ref callback each render would re-add the listener.
13+
"use memo";
14+
return (element: HTMLElement | null) => {
15+
if (!element) return;
16+
element.addEventListener("beforematch", onReveal);
17+
return () => element.removeEventListener("beforematch", onReveal);
18+
};
2019
}

0 commit comments

Comments
 (0)