Dashboard/RefreshPicker: Prevents unnecessary redrawing of RefreshPicker (#26902)

Closes #26823
This commit is contained in:
kay delaney 2020-08-11 15:36:50 +01:00 committed by GitHub
parent eb985ffbee
commit e4da0fcb5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,6 +64,22 @@ export class RefreshPickerBase extends PureComponent<Props> {
}
};
shouldComponentUpdate(nextProps: Props) {
const intervalsDiffer = nextProps.intervals?.some((interval, i) => this.props.intervals?.[i] !== interval);
return (
intervalsDiffer ||
this.props.onRefresh !== nextProps.onRefresh ||
this.props.onIntervalChanged !== nextProps.onIntervalChanged ||
this.props.value !== nextProps.value ||
this.props.tooltip !== nextProps.tooltip ||
this.props.hasLiveOption !== nextProps.hasLiveOption ||
this.props.refreshButton !== nextProps.refreshButton ||
this.props.buttonSelectClassName !== nextProps.buttonSelectClassName ||
this.props.theme !== nextProps.theme
);
}
render() {
const { onRefresh, intervals, tooltip, value, refreshButton, buttonSelectClassName, theme } = this.props;
const options = this.intervalsToOptions(intervals);