Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use deep equality check for plugin props on componentDidUpdate to avoid unnecessary updates #254

Merged
merged 1 commit into from
Apr 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/plugin/src/ChartPlugin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';

import isEqual from 'lodash-es/isEqual';
import { createChart } from 'd2-charts-api';

import { apiFetchVisualization } from './api/visualization';
Expand Down Expand Up @@ -32,12 +32,12 @@ class ChartPlugin extends Component {
}

componentDidUpdate(prevProps) {
if (this.props.config !== prevProps.config) {
if (!isEqual(this.props.config, prevProps.config)) {
this.renderChart();
return;
}

if (this.props.filters !== prevProps.filters) {
if (!isEqual(this.props.filters, prevProps.filters)) {
this.renderChart();
return;
}
Expand Down