Skip to content

Commit

Permalink
fix: Removes Redux state mutations - iteration 3
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina committed Apr 10, 2023
1 parent b613167 commit 3a8aaa7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions superset-frontend/src/components/Chart/ChartRenderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { snakeCase, isEqual } from 'lodash';
import { snakeCase, isEqual, cloneDeep } from 'lodash';
import PropTypes from 'prop-types';
import React from 'react';
import {
Expand Down Expand Up @@ -250,6 +250,11 @@ class ChartRenderer extends React.Component {
postTransformProps,
} = this.props;

// 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
const mutableQueriesResponse = cloneDeep(queriesResponse);

const currentFormData =
chartIsStale && latestQueryFormData ? latestQueryFormData : formData;
const vizType = currentFormData.viz_type || this.props.vizType;
Expand Down Expand Up @@ -339,7 +344,7 @@ class ChartRenderer extends React.Component {
filterState={filterState}
hooks={this.hooks}
behaviors={behaviors}
queriesData={queriesResponse}
queriesData={mutableQueriesResponse}
onRenderSuccess={this.handleRenderSuccess}
onRenderFailure={this.handleRenderFailure}
noResults={noResultsComponent}
Expand Down

0 comments on commit 3a8aaa7

Please sign in to comment.