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.width = 300;
this.height = 100; this.height = 100;
this.marginBottom = 20; this.marginBottom = 20;
this.histogramCache = {};
this.state = { this.state = {
svg: null, svg: null,
@@ -55,8 +56,6 @@ class HistogramBrush extends React.Component {
nextProps.metadataField nextProps.metadataField
); );
this.histogramCache = {};
this.histogramCache.x = d3 this.histogramCache.x = d3
.scaleLinear() .scaleLinear()
.domain([nextProps.ranges.min, nextProps.ranges.max]) .domain([nextProps.ranges.min, nextProps.ranges.max])
@@ -81,7 +80,7 @@ class HistogramBrush extends React.Component {
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
if ( if (
this.props.metadataField !== nextProps.metadataField || this.props.metadataField !== nextProps.metadataField ||
!this.histogramCache !this.histogramCache.x
) { ) {
this.calcHistogramCache(nextProps); this.calcHistogramCache(nextProps);
} }