mirror of https://github.com/buster-so/buster.git
Remove some unecssary memo
This commit is contained in:
parent
991dd172f6
commit
2f324baa62
|
@ -9,8 +9,7 @@ import type { DropdownItems } from '../dropdown';
|
|||
import Link from 'next/link';
|
||||
import { PreparingYourRequestLoader } from '../charts/LoadingComponents';
|
||||
|
||||
export const MetricCard = React.memo(
|
||||
React.forwardRef<
|
||||
export const MetricCard = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
{
|
||||
className?: string;
|
||||
|
@ -19,9 +18,7 @@ export const MetricCard = React.memo(
|
|||
isDragOverlay: boolean;
|
||||
readOnly: boolean;
|
||||
metricData: BusterMetricData | undefined;
|
||||
metric:
|
||||
| Pick<BusterMetric, 'name' | 'time_frame' | 'chart_config' | 'description'>
|
||||
| undefined;
|
||||
metric: Pick<BusterMetric, 'name' | 'time_frame' | 'chart_config' | 'description'> | undefined;
|
||||
renderChart: boolean;
|
||||
loading: boolean;
|
||||
error: string | undefined;
|
||||
|
@ -31,7 +28,7 @@ export const MetricCard = React.memo(
|
|||
listeners?: DraggableSyntheticListeners;
|
||||
threeDotMenuItems: DropdownItems;
|
||||
}
|
||||
>(
|
||||
>(
|
||||
(
|
||||
{
|
||||
className = '',
|
||||
|
@ -109,5 +106,4 @@ export const MetricCard = React.memo(
|
|||
</Card>
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
|
|
@ -2,16 +2,15 @@ import { cn } from '@/lib/classMerge';
|
|||
import React, { useState } from 'react';
|
||||
import { Dropdown, type DropdownItems } from '../dropdown';
|
||||
|
||||
export const MetricCardThreeMenuContainer = React.memo(
|
||||
({
|
||||
export const MetricCardThreeMenuContainer = ({
|
||||
children,
|
||||
dropdownItems,
|
||||
className
|
||||
}: {
|
||||
}: {
|
||||
className?: string;
|
||||
children: React.ReactNode;
|
||||
dropdownItems: DropdownItems;
|
||||
}) => {
|
||||
}) => {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
return (
|
||||
|
@ -32,7 +31,6 @@ export const MetricCardThreeMenuContainer = React.memo(
|
|||
</Dropdown>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
MetricCardThreeMenuContainer.displayName = 'MetricCardThreeMenuContainer';
|
||||
|
|
|
@ -20,8 +20,7 @@ export const MetricTitle: React.FC<{
|
|||
isDragOverlay: boolean;
|
||||
readOnly?: boolean;
|
||||
threeDotMenuItems: DropdownItems;
|
||||
}> = React.memo(
|
||||
({
|
||||
}> = ({
|
||||
readOnly = true,
|
||||
name,
|
||||
description,
|
||||
|
@ -29,7 +28,7 @@ export const MetricTitle: React.FC<{
|
|||
metricLink,
|
||||
timeFrame,
|
||||
threeDotMenuItems
|
||||
}) => {
|
||||
}) => {
|
||||
const router = useRouter();
|
||||
|
||||
useMount(() => {
|
||||
|
@ -71,6 +70,5 @@ export const MetricTitle: React.FC<{
|
|||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
MetricTitle.displayName = 'MetricTitle';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use client';
|
||||
|
||||
import React, { useMemo,useContext } from 'react';
|
||||
import React, { useMemo, useContext } from 'react';
|
||||
import { useMemoizedFn } from '@/hooks';
|
||||
import { useDashboardMetric } from './useDashboardMetric';
|
||||
import { assetParamsToRoute } from '@/lib/assets';
|
||||
|
@ -47,10 +47,8 @@ const DashboardMetricItemBase: React.FC<{
|
|||
const animate =
|
||||
!initialAnimationEnded && !isDragOverlay && dataLength < 125 && numberOfMetrics <= 30;
|
||||
|
||||
const error: string | undefined = useMemo(
|
||||
() => metric?.error || metricDataError?.message || metricError?.message || undefined,
|
||||
[metric?.error, metricDataError, metricError]
|
||||
);
|
||||
const error: string | undefined =
|
||||
metric?.error || metricDataError?.message || metricError?.message || undefined;
|
||||
|
||||
const metricLink = useMemo(() => {
|
||||
return assetParamsToRoute({
|
||||
|
@ -92,4 +90,4 @@ const DashboardMetricItemBase: React.FC<{
|
|||
);
|
||||
};
|
||||
|
||||
export const DashboardMetricItem = React.memo(DashboardMetricItemBase);
|
||||
export const DashboardMetricItem = DashboardMetricItemBase;
|
||||
|
|
Loading…
Reference in New Issue