move initializer to constructor

This commit is contained in:
bkmartinjr
2018-05-14 16:04:31 -07:00
parent fe655135e4
commit 1e88764132
+2 -3
View File
@@ -36,6 +36,7 @@ class HistogramBrush extends React.Component {
this.width = 300;
this.height = 100;
this.marginBottom = 20;
this.histogramCache = {};
this.state = {
svg: null,
@@ -55,8 +56,6 @@ class HistogramBrush extends React.Component {
nextProps.metadataField
);
this.histogramCache = {};
this.histogramCache.x = d3
.scaleLinear()
.domain([nextProps.ranges.min, nextProps.ranges.max])
@@ -81,7 +80,7 @@ class HistogramBrush extends React.Component {
componentWillReceiveProps(nextProps) {
if (
this.props.metadataField !== nextProps.metadataField ||
!this.histogramCache
!this.histogramCache.x
) {
this.calcHistogramCache(nextProps);
}