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

(cherry picked from commit f774c4a076)
This commit is contained in:
Torkel Ödegaard
2020-01-15 10:36:39 +01:00
committed by Andrej Ocenas
parent 89f040fb03
commit 1a057dac84
@@ -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() {