Skip to content

Commit 2bb92ba

Browse files
perf(web): the environment selector compiles without manual memoization (#20575)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent dd1ab3f commit 2bb92ba

1 file changed

Lines changed: 12 additions & 16 deletions

File tree

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

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ComposerContextLabel } from "./ComposerContextLabel";
33
import { Tooltip, TooltipTrigger, TooltipPopup } from "./ui/tooltip";
44
import type { EnvironmentId } from "@t3tools/contracts";
55
import { ScaleIcon } from "lucide-react";
6-
import { memo, useMemo } from "react";
6+
import { memo } from "react";
77

88
import type { EnvironmentOption } from "./BranchToolbar.logic";
99
import { EnvironmentMachineIcon } from "./EnvironmentMachineIcon";
@@ -35,22 +35,18 @@ export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvir
3535
onEnvironmentChange,
3636
}: BranchToolbarEnvironmentSelectorProps) {
3737
const composerFloatingLayerProps = useComposerMenuProps();
38-
const activeEnvironment = useMemo(() => {
39-
return availableEnvironments.find((env) => env.environmentId === environmentId) ?? null;
40-
}, [availableEnvironments, environmentId]);
38+
const activeEnvironment =
39+
availableEnvironments.find((env) => env.environmentId === environmentId) ?? null;
4140

42-
const environmentItems = useMemo(
43-
() => [
44-
...(onAutoEnvironment
45-
? [{ value: "auto", label: autoEnvironmentLabel ?? "Auto balance" }]
46-
: []),
47-
...availableEnvironments.map((env) => ({
48-
value: env.environmentId,
49-
label: env.label,
50-
})),
51-
],
52-
[availableEnvironments, autoEnvironmentLabel, onAutoEnvironment],
53-
);
41+
const environmentItems = [
42+
...(onAutoEnvironment
43+
? [{ value: "auto", label: autoEnvironmentLabel ?? "Auto balance" }]
44+
: []),
45+
...availableEnvironments.map((env) => ({
46+
value: env.environmentId,
47+
label: env.label,
48+
})),
49+
];
5450

5551
// The static label carries the xs control's height (h-7 sm:h-6) as well as
5652
// its padding: the composer context strip has no min-height of its own, and

0 commit comments

Comments
 (0)