Cloudwatch: Fixed crash when switching from cloudwatch data source (#21376)

This commit is contained in:
Torkel Ödegaard 2020-01-07 13:05:14 +01:00 committed by GitHub
parent b4fa27b8a4
commit f774c4a076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,8 +28,8 @@ const idValidationEvents: ValidationEvents = {
export class QueryEditor extends PureComponent<Props, State> {
state: State = { regions: [], namespaces: [], metricNames: [], variableOptionGroup: {}, showMeta: false };
componentWillMount() {
const { query } = this.props;
static getDerivedStateFromProps(props: Props, state: State) {
const { query } = props;
if (!query.namespace) {
query.namespace = '';
@ -66,6 +66,8 @@ export class QueryEditor extends PureComponent<Props, State> {
if (!query.hasOwnProperty('matchExact')) {
query.matchExact = true;
}
return state;
}
componentDidMount() {