TypeScript
perf(web): the environment selector compiles without manual memoization (#20575)
Julius Marminge2bb92ba474f3
diff --git a/apps/web/src/components/BranchToolbarEnvironmentSelector.tsx b/apps/web/src/components/BranchToolbarEnvironmentSelector.tsxindex e323c709212..f1647a812a1 100644--- a/apps/web/src/components/BranchToolbarEnvironmentSelector.tsx+++ b/apps/web/src/components/BranchToolbarEnvironmentSelector.tsx@@ -3,7 +3,7 @@ import { ComposerContextLabel } from "./ComposerContextLabel";import { Tooltip, TooltipTrigger, TooltipPopup } from "./ui/tooltip";import type { EnvironmentId } from "@t3tools/contracts";import { ScaleIcon } from "lucide-react";-import { memo, useMemo } from "react";+import { memo } from "react";import type { EnvironmentOption } from "./BranchToolbar.logic";import { EnvironmentMachineIcon } from "./EnvironmentMachineIcon";@@ -35,22 +35,18 @@ export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvironEnvironmentChange,}: BranchToolbarEnvironmentSelectorProps) {const composerFloatingLayerProps = useComposerMenuProps();- const activeEnvironment = useMemo(() => {- return availableEnvironments.find((env) => env.environmentId === environmentId) ?? null;- }, [availableEnvironments, environmentId]);+ const activeEnvironment =+ availableEnvironments.find((env) => env.environmentId === environmentId) ?? null;- const environmentItems = useMemo(- () => [- ...(onAutoEnvironment- ? [{ value: "auto", label: autoEnvironmentLabel ?? "Auto balance" }]- : []),- ...availableEnvironments.map((env) => ({- value: env.environmentId,- label: env.label,- })),- ],- [availableEnvironments, autoEnvironmentLabel, onAutoEnvironment],- );+ const environmentItems = [+ ...(onAutoEnvironment+ ? [{ value: "auto", label: autoEnvironmentLabel ?? "Auto balance" }]+ : []),+ ...availableEnvironments.map((env) => ({+ value: env.environmentId,+ label: env.label,+ })),+ ];// The static label carries the xs control's height (h-7 sm:h-6) as well as// its padding: the composer context strip has no min-height of its own, and