mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
elastic: eliminate react warning (#52934)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { Context, createContext, PropsWithChildren, useCallback, useContext } from 'react';
|
||||
import React, { Context, createContext, PropsWithChildren, useCallback, useContext, useEffect } from 'react';
|
||||
|
||||
import { TimeRange } from '@grafana/data';
|
||||
|
||||
@@ -52,11 +52,18 @@ export const ElasticsearchProvider = ({
|
||||
reducer
|
||||
);
|
||||
|
||||
const isUninitialized = !query.metrics || !query.bucketAggs || query.query === undefined;
|
||||
|
||||
// This initializes the query by dispatching an init action to each reducer.
|
||||
// useStatelessReducer will then call `onChange` with the newly generated query
|
||||
if (!query.metrics || !query.bucketAggs || query.query === undefined) {
|
||||
dispatch(initQuery());
|
||||
|
||||
useEffect(() => {
|
||||
if (isUninitialized) {
|
||||
dispatch(initQuery());
|
||||
}
|
||||
});
|
||||
|
||||
if (isUninitialized) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user