CloudMonitor: Correctly re-render VisualMetricQueryEditor on TimeRange updates (#66756)

Compare string value rather than object
This commit is contained in:
Andreas Christou
2023-04-18 16:45:59 +01:00
committed by GitHub
parent c0799345dd
commit adf12d0e90
@@ -48,7 +48,11 @@ export function Editor({
const [timeRange, setTimeRange] = useState<TimeRange>({ ...datasource.timeSrv.timeRange() });
const useTime = (time: TimeRange) => {
if (timeRange !== null && (timeRange.raw.from !== time.raw.from || timeRange.raw.to !== time.raw.to)) {
if (
timeRange !== null &&
(timeRange.raw.from.toString() !== time.raw.from.toString() ||
timeRange.raw.to.toString() !== time.raw.to.toString())
) {
setTimeRange({ ...time });
}
};