@devries-cameron20 / t3code Mirror · read-only / commits / fea5380159
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 06:45 UTC

perf(web): the find reveal ref compiles without manual memoization (#20555)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 16, 2026 at 22:08 UTC fea5380159feb04b6d21233fadfb0705b30fa67d
1 file changed +8 -9
apps/web/src/components/chat/markdownFindContext.ts
+8 -9
@@ -1,4 +1,4 @@
1 -import { createContext, useCallback } from "react";
1 +import { createContext } from "react";
2
3 // While find is active, folded content stays mounted (hidden) so its text can be
4 // matched. Nothing opens until the selected match lies inside it.
@@ -9,12 +9,11 @@ export const MarkdownFindContext = createContext(false);
9 * match, like the browser's own find-in-page. `onReveal` must be stable.
10 */
11 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 + };
19 }