LegendIcon: only render color picker when the props change (#33141)

pull/32579/head^2
Ryan McKinley 5 years ago committed by GitHub
parent 18bbbaf53e
commit af46bbf654
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      packages/grafana-ui/src/components/VizLegend/VizLegendSeriesIcon.tsx

@ -8,10 +8,8 @@ interface Props {
onColorChange: (color: string) => void; onColorChange: (color: string) => void;
} }
/** export const VizLegendSeriesIcon = React.memo<Props>(
* @internal ({ disabled, color, onColorChange }) => {
*/
export const VizLegendSeriesIcon: React.FunctionComponent<Props> = ({ disabled, color, onColorChange }) => {
return disabled ? ( return disabled ? (
<SeriesIcon color={color} /> <SeriesIcon color={color} />
) : ( ) : (
@ -27,6 +25,12 @@ export const VizLegendSeriesIcon: React.FunctionComponent<Props> = ({ disabled,
)} )}
</SeriesColorPicker> </SeriesColorPicker>
); );
}; },
// areEqual -- return true if they are the same.
// onColorChange updates frequently, so ignore that
(prevProps, nextProps) => {
return prevProps.color === nextProps.color && prevProps.disabled === nextProps.disabled;
}
);
VizLegendSeriesIcon.displayName = 'VizLegendSeriesIcon'; VizLegendSeriesIcon.displayName = 'VizLegendSeriesIcon';

Loading…
Cancel
Save