Commit 6da87a17 by Torkel Ödegaard Committed by GitHub

Merge pull request #15793 from grafana/hugoh/bug-can-not-use-testdatasource-in-v6

Update datasource in componentDidUpdate so that datasource is correct in state
parents ef59af5e 09b036dc
......@@ -64,6 +64,14 @@ export class DataSourceSettingsPage extends PureComponent<Props, State> {
await loadDataSource(pageId);
}
componentDidUpdate(prevProps: Props) {
const { dataSource } = this.props;
if (prevProps.dataSource !== dataSource) {
this.setState({ dataSource });
}
}
onSubmit = async (evt: React.FormEvent<HTMLFormElement>) => {
evt.preventDefault();
......@@ -95,9 +103,7 @@ export class DataSourceSettingsPage extends PureComponent<Props, State> {
};
onModelChange = (dataSource: DataSourceSettings) => {
this.setState({
dataSource: dataSource,
});
this.setState({ dataSource });
};
isReadOnly() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment