Run test datasource query when mounted

This commit is contained in:
Kristina Durivage 2023-04-03 11:08:46 -05:00
parent 1380fa54d6
commit 28b37e4df9

View File

@ -1,4 +1,4 @@
import React, { FormEvent, useMemo } from 'react';
import React, { FormEvent, useEffect, useMemo } from 'react';
import { useAsync } from 'react-use';
import { QueryEditorProps, SelectableValue } from '@grafana/data';
@ -64,6 +64,12 @@ export const QueryEditor = ({ query, datasource, onChange, onRunQuery }: Props)
}));
}, []);
// run the query once on mount using default selection
useEffect(() => {
onUpdate(query);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const onUpdate = (query: TestData) => {
onChange(query);
onRunQuery();