TypeScript
perf(web): the guide file diff compiles without manual memoization (#20544)
Julius Marminge02d48aec5c75
diff --git a/apps/web/src/components/pullRequest/guide/GuideFileDiff.tsx b/apps/web/src/components/pullRequest/guide/GuideFileDiff.tsxindex 9d2cb6545c7..adcb665f3d9 100644--- a/apps/web/src/components/pullRequest/guide/GuideFileDiff.tsx+++ b/apps/web/src/components/pullRequest/guide/GuideFileDiff.tsx@@ -4,7 +4,6 @@ import {type FileDiffMetadata,} from "@pierre/diffs";import { FileDiff } from "@pierre/diffs/react";-import { useMemo } from "react";import { useTheme } from "~/hooks/useTheme";import { resolveDiffThemeName } from "~/lib/diffRendering";@@ -22,21 +21,18 @@ export function GuideFileDiff({const { resolvedTheme } = useTheme();// Loading the unchanged lines rewrites the diff it is given; the excerpts read the same file// as a patch, so this view expands a copy of its own.- const expandable = useMemo(() => cloneFileDiffMetadata(file), [file]);- const options = useMemo(- () => ({- diffStyle: "unified" as const,- lineDiffType: "none" as const,- overflow: "scroll" as const,- disableFileHeader: true,- theme: resolveDiffThemeName(resolvedTheme),- themeType: resolvedTheme,- preferredHighlighter: PREFERRED_HIGHLIGHTER,- unsafeCSS: DIFF_VIEW_UNSAFE_CSS,- loadDiffFiles,- }),- [loadDiffFiles, resolvedTheme],- );+ const expandable = cloneFileDiffMetadata(file);+ const options = {+ diffStyle: "unified" as const,+ lineDiffType: "none" as const,+ overflow: "scroll" as const,+ disableFileHeader: true,+ theme: resolveDiffThemeName(resolvedTheme),+ themeType: resolvedTheme,+ preferredHighlighter: PREFERRED_HIGHLIGHTER,+ unsafeCSS: DIFF_VIEW_UNSAFE_CSS,+ loadDiffFiles,+ };return (<div className="border-t border-border/60"><FileDiff fileDiff={expandable} options={options} />