diff --git a/frontend/src/container/GridGraphLayout/Graph/index.tsx b/frontend/src/container/GridGraphLayout/Graph/index.tsx index e4f543b7d5..169582ed95 100644 --- a/frontend/src/container/GridGraphLayout/Graph/index.tsx +++ b/frontend/src/container/GridGraphLayout/Graph/index.tsx @@ -83,6 +83,11 @@ function GridCardGraph({ const updatedQuery = useStepInterval(widget?.query); + const isEmptyWidget = useMemo( + () => widget?.id === 'empty' || isEmpty(widget), + [widget], + ); + const queryResponse = useGetQueryRange( { selectedTime: widget?.timePreferance, @@ -101,7 +106,7 @@ function GridCardGraph({ variables, ], keepPreviousData: true, - enabled: isGraphVisible, + enabled: isGraphVisible && !isEmptyWidget, refetchOnMount: false, onError: (error) => { setErrorMessage(error.message); @@ -131,8 +136,6 @@ function GridCardGraph({ ); const onDeleteHandler = useCallback(() => { - const isEmptyWidget = widget?.id === 'empty' || isEmpty(widget); - const widgetId = isEmptyWidget ? layout[0].i : widget?.id; featureResponse @@ -147,7 +150,8 @@ function GridCardGraph({ }); }); }, [ - widget, + isEmptyWidget, + widget?.id, layout, featureResponse, deleteWidget,