Skip to content

Commit

Permalink
Update frequencies panel when data changes
Browse files Browse the repository at this point in the history
The frequencies component performed some basic comparisons between the previously rendered data and new data to avoid unnecessary re-renders. This logic was too simplistic and caused a bug where the component wouldn't re-render the graph when the data had indeed changed. This commit skips these checks. This may result in some unnecessary re-renders, however I couldn't find any in my testing.

Closes #1224
  • Loading branch information
jameshadfield committed Mar 9, 2021
1 parent 0de2197 commit 658f8dc
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/components/frequencies/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'd3-transition';
import { connect } from "react-redux";
import Card from "../framework/card";
import { calcXScale, calcYScale, drawXAxis, drawYAxis, drawProjectionInfo,
areListsEqual, drawStream, processMatrix, parseColorBy, normString } from "./functions";
drawStream, processMatrix, parseColorBy, normString } from "./functions";
import "../../css/entropy.css";

@connect((state) => {
Expand Down Expand Up @@ -50,8 +50,6 @@ class Frequencies extends React.Component {
/* we don't have to check width / height changes here - that's done in componentDidUpdate */
const data = processMatrix({...newProps});
const maxYChange = oldState.maxY !== data.maxY;
const catChange = !areListsEqual(oldState.categories, data.categories);
if (!maxYChange && !catChange) return false;
const chartGeom = this.calcChartGeom(newProps.width, newProps.height);
/* should the y scale be updated? */
let newScales;
Expand Down

0 comments on commit 658f8dc

Please sign in to comment.