Remove some unecssary memo

This commit is contained in:
Nate Kelley 2025-08-07 15:28:53 -06:00
parent 991dd172f6
commit 2f324baa62
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
4 changed files with 172 additions and 182 deletions

View File

@ -9,8 +9,7 @@ import type { DropdownItems } from '../dropdown';
import Link from 'next/link'; import Link from 'next/link';
import { PreparingYourRequestLoader } from '../charts/LoadingComponents'; import { PreparingYourRequestLoader } from '../charts/LoadingComponents';
export const MetricCard = React.memo( export const MetricCard = React.forwardRef<
React.forwardRef<
HTMLDivElement, HTMLDivElement,
{ {
className?: string; className?: string;
@ -19,9 +18,7 @@ export const MetricCard = React.memo(
isDragOverlay: boolean; isDragOverlay: boolean;
readOnly: boolean; readOnly: boolean;
metricData: BusterMetricData | undefined; metricData: BusterMetricData | undefined;
metric: metric: Pick<BusterMetric, 'name' | 'time_frame' | 'chart_config' | 'description'> | undefined;
| Pick<BusterMetric, 'name' | 'time_frame' | 'chart_config' | 'description'>
| undefined;
renderChart: boolean; renderChart: boolean;
loading: boolean; loading: boolean;
error: string | undefined; error: string | undefined;
@ -31,7 +28,7 @@ export const MetricCard = React.memo(
listeners?: DraggableSyntheticListeners; listeners?: DraggableSyntheticListeners;
threeDotMenuItems: DropdownItems; threeDotMenuItems: DropdownItems;
} }
>( >(
( (
{ {
className = '', className = '',
@ -109,5 +106,4 @@ export const MetricCard = React.memo(
</Card> </Card>
); );
} }
)
); );

View File

@ -2,16 +2,15 @@ import { cn } from '@/lib/classMerge';
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Dropdown, type DropdownItems } from '../dropdown'; import { Dropdown, type DropdownItems } from '../dropdown';
export const MetricCardThreeMenuContainer = React.memo( export const MetricCardThreeMenuContainer = ({
({
children, children,
dropdownItems, dropdownItems,
className className
}: { }: {
className?: string; className?: string;
children: React.ReactNode; children: React.ReactNode;
dropdownItems: DropdownItems; dropdownItems: DropdownItems;
}) => { }) => {
const [isOpen, setIsOpen] = useState(false); const [isOpen, setIsOpen] = useState(false);
return ( return (
@ -32,7 +31,6 @@ export const MetricCardThreeMenuContainer = React.memo(
</Dropdown> </Dropdown>
</div> </div>
); );
} };
);
MetricCardThreeMenuContainer.displayName = 'MetricCardThreeMenuContainer'; MetricCardThreeMenuContainer.displayName = 'MetricCardThreeMenuContainer';

View File

@ -20,8 +20,7 @@ export const MetricTitle: React.FC<{
isDragOverlay: boolean; isDragOverlay: boolean;
readOnly?: boolean; readOnly?: boolean;
threeDotMenuItems: DropdownItems; threeDotMenuItems: DropdownItems;
}> = React.memo( }> = ({
({
readOnly = true, readOnly = true,
name, name,
description, description,
@ -29,7 +28,7 @@ export const MetricTitle: React.FC<{
metricLink, metricLink,
timeFrame, timeFrame,
threeDotMenuItems threeDotMenuItems
}) => { }) => {
const router = useRouter(); const router = useRouter();
useMount(() => { useMount(() => {
@ -71,6 +70,5 @@ export const MetricTitle: React.FC<{
)} )}
</div> </div>
); );
} };
);
MetricTitle.displayName = 'MetricTitle'; MetricTitle.displayName = 'MetricTitle';

View File

@ -1,6 +1,6 @@
'use client'; 'use client';
import React, { useMemo,useContext } from 'react'; import React, { useMemo, useContext } from 'react';
import { useMemoizedFn } from '@/hooks'; import { useMemoizedFn } from '@/hooks';
import { useDashboardMetric } from './useDashboardMetric'; import { useDashboardMetric } from './useDashboardMetric';
import { assetParamsToRoute } from '@/lib/assets'; import { assetParamsToRoute } from '@/lib/assets';
@ -47,10 +47,8 @@ const DashboardMetricItemBase: React.FC<{
const animate = const animate =
!initialAnimationEnded && !isDragOverlay && dataLength < 125 && numberOfMetrics <= 30; !initialAnimationEnded && !isDragOverlay && dataLength < 125 && numberOfMetrics <= 30;
const error: string | undefined = useMemo( const error: string | undefined =
() => metric?.error || metricDataError?.message || metricError?.message || undefined, metric?.error || metricDataError?.message || metricError?.message || undefined;
[metric?.error, metricDataError, metricError]
);
const metricLink = useMemo(() => { const metricLink = useMemo(() => {
return assetParamsToRoute({ return assetParamsToRoute({
@ -92,4 +90,4 @@ const DashboardMetricItemBase: React.FC<{
); );
}; };
export const DashboardMetricItem = React.memo(DashboardMetricItemBase); export const DashboardMetricItem = DashboardMetricItemBase;