mirror of
https://github.com/apache/superset.git
synced 2024-09-18 19:49:37 -04:00
fix: Removes Redux state mutations - iteration 3 (#23637)
This commit is contained in:
parent
ca408a7159
commit
8bd8276791
@ -16,7 +16,7 @@
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
import { snakeCase, isEqual } from 'lodash';
|
import { snakeCase, isEqual, cloneDeep } from 'lodash';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {
|
import {
|
||||||
@ -117,6 +117,11 @@ class ChartRenderer extends React.Component {
|
|||||||
this.props.actions?.updateDataMask(this.props.chartId, dataMask);
|
this.props.actions?.updateDataMask(this.props.chartId, dataMask);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: queriesResponse comes from Redux store but it's being edited by
|
||||||
|
// the plugins, hence we need to clone it to avoid state mutation
|
||||||
|
// until we change the reducers to use Redux Toolkit with Immer
|
||||||
|
this.mutableQueriesResponse = cloneDeep(this.props.queriesResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps, nextState) {
|
shouldComponentUpdate(nextProps, nextState) {
|
||||||
@ -131,6 +136,11 @@ class ChartRenderer extends React.Component {
|
|||||||
}
|
}
|
||||||
this.hasQueryResponseChange =
|
this.hasQueryResponseChange =
|
||||||
nextProps.queriesResponse !== this.props.queriesResponse;
|
nextProps.queriesResponse !== this.props.queriesResponse;
|
||||||
|
|
||||||
|
if (this.hasQueryResponseChange) {
|
||||||
|
this.mutableQueriesResponse = cloneDeep(nextProps.queriesResponse);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
this.hasQueryResponseChange ||
|
this.hasQueryResponseChange ||
|
||||||
!isEqual(nextProps.datasource, this.props.datasource) ||
|
!isEqual(nextProps.datasource, this.props.datasource) ||
|
||||||
@ -246,7 +256,6 @@ class ChartRenderer extends React.Component {
|
|||||||
chartIsStale,
|
chartIsStale,
|
||||||
formData,
|
formData,
|
||||||
latestQueryFormData,
|
latestQueryFormData,
|
||||||
queriesResponse,
|
|
||||||
postTransformProps,
|
postTransformProps,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
@ -339,7 +348,7 @@ class ChartRenderer extends React.Component {
|
|||||||
filterState={filterState}
|
filterState={filterState}
|
||||||
hooks={this.hooks}
|
hooks={this.hooks}
|
||||||
behaviors={behaviors}
|
behaviors={behaviors}
|
||||||
queriesData={queriesResponse}
|
queriesData={this.mutableQueriesResponse}
|
||||||
onRenderSuccess={this.handleRenderSuccess}
|
onRenderSuccess={this.handleRenderSuccess}
|
||||||
onRenderFailure={this.handleRenderFailure}
|
onRenderFailure={this.handleRenderFailure}
|
||||||
noResults={noResultsComponent}
|
noResults={noResultsComponent}
|
||||||
|
Loading…
Reference in New Issue
Block a user