diff --git a/showcase/examples/force-directed-graph/force-directed-graph.js b/showcase/examples/force-directed-graph/force-directed-graph.js index b3c97c2fd..f6b80cf22 100644 --- a/showcase/examples/force-directed-graph/force-directed-graph.js +++ b/showcase/examples/force-directed-graph/force-directed-graph.js @@ -99,10 +99,12 @@ class ForceDirectedGraph extends React.Component { }; } - componentWillReceiveProps(nextProps) { - this.setState({ - data: generateSimulation(nextProps) - }); + componentDidUpdate(prevProps, prevState, snapshot) { + if (this.props !== prevProps) { + this.setState({ + data: generateSimulation(this.props) + }); + } } render() { diff --git a/showcase/examples/responsive-vis/responsive-scatterplot.js b/showcase/examples/responsive-vis/responsive-scatterplot.js index 6421c3351..e0b6d2abd 100644 --- a/showcase/examples/responsive-vis/responsive-scatterplot.js +++ b/showcase/examples/responsive-vis/responsive-scatterplot.js @@ -74,15 +74,16 @@ export default class ResponsiveScatterplot extends React.Component { selectedPoints: [] }; - componentWillReceiveProps(nextProps) { - // not the greatest - this.setState({ - binData: transformToBinData( - nextProps.data, - nextProps.width, - nextProps.height - ) - }); + componentDidUpdate(prevProps, prevState, snapshot) { + if (this.props !== prevProps) { + this.setState({ + binData: transformToBinData( + this.props.data, + this.props.width, + this.props.height + ) + }); + } } getFeatures() { diff --git a/showcase/package-lock.json b/showcase/package-lock.json index e6e6431ee..254766862 100644 --- a/showcase/package-lock.json +++ b/showcase/package-lock.json @@ -861,7 +861,7 @@ "dev": true }, "debug": { - "version": "2.6.9", + "version": "2.6.8", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", "dev": true, @@ -1118,6 +1118,12 @@ "vary": "~1.1.1" }, "dependencies": { + "fresh": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.0.tgz", + "integrity": "sha1-9HTKXmqSRtb9jglTz6m5yAWvp44=", + "dev": true + }, "path-to-regexp": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", @@ -1277,12 +1283,6 @@ "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=", "dev": true }, - "fresh": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.0.tgz", - "integrity": "sha1-9HTKXmqSRtb9jglTz6m5yAWvp44=", - "dev": true - }, "fsevents": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.2.tgz", @@ -1313,7 +1313,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.1.1", @@ -1364,7 +1365,8 @@ "balanced-match": { "version": "0.4.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "bcrypt-pbkdf": { "version": "1.0.1", @@ -1379,6 +1381,7 @@ "version": "0.0.9", "bundled": true, "dev": true, + "optional": true, "requires": { "inherits": "~2.0.0" } @@ -1387,6 +1390,7 @@ "version": "2.10.1", "bundled": true, "dev": true, + "optional": true, "requires": { "hoek": "2.x.x" } @@ -1395,6 +1399,7 @@ "version": "1.1.7", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^0.4.1", "concat-map": "0.0.1" @@ -1403,7 +1408,8 @@ "buffer-shims": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "caseless": { "version": "0.12.0", @@ -1420,12 +1426,14 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "combined-stream": { "version": "1.0.5", "bundled": true, "dev": true, + "optional": true, "requires": { "delayed-stream": "~1.0.0" } @@ -1433,17 +1441,20 @@ "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "cryptiles": { "version": "2.0.5", @@ -1489,7 +1500,8 @@ "delayed-stream": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "delegates": { "version": "1.0.0", @@ -1515,7 +1527,8 @@ "extsprintf": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "forever-agent": { "version": "0.6.1", @@ -1537,12 +1550,14 @@ "fs.realpath": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "fstream": { "version": "1.0.11", "bundled": true, "dev": true, + "optional": true, "requires": { "graceful-fs": "^4.1.2", "inherits": "~2.0.0", @@ -1598,6 +1613,7 @@ "version": "7.1.2", "bundled": true, "dev": true, + "optional": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -1610,7 +1626,8 @@ "graceful-fs": { "version": "4.1.11", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "har-schema": { "version": "1.0.5", @@ -1649,7 +1666,8 @@ "hoek": { "version": "2.16.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "http-signature": { "version": "1.1.1", @@ -1666,6 +1684,7 @@ "version": "1.0.6", "bundled": true, "dev": true, + "optional": true, "requires": { "once": "^1.3.0", "wrappy": "1" @@ -1674,7 +1693,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.4", @@ -1686,6 +1706,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -1699,7 +1720,8 @@ "isarray": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "isstream": { "version": "0.1.2", @@ -1772,12 +1794,14 @@ "mime-db": { "version": "1.27.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "mime-types": { "version": "2.1.15", "bundled": true, "dev": true, + "optional": true, "requires": { "mime-db": "~1.27.0" } @@ -1786,6 +1810,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -1793,12 +1818,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "mkdirp": { "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -1851,7 +1878,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "oauth-sign": { "version": "0.8.2", @@ -1869,6 +1897,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -1898,7 +1927,8 @@ "path-is-absolute": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "performance-now": { "version": "0.2.0", @@ -1909,7 +1939,8 @@ "process-nextick-args": { "version": "1.0.7", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "punycode": { "version": "1.4.1", @@ -1947,6 +1978,7 @@ "version": "2.2.9", "bundled": true, "dev": true, + "optional": true, "requires": { "buffer-shims": "~1.0.0", "core-util-is": "~1.0.0", @@ -1991,6 +2023,7 @@ "version": "2.6.1", "bundled": true, "dev": true, + "optional": true, "requires": { "glob": "^7.0.5" } @@ -1998,7 +2031,8 @@ "safe-buffer": { "version": "5.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "semver": { "version": "5.3.0", @@ -2056,6 +2090,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2066,6 +2101,7 @@ "version": "1.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.0.1" } @@ -2080,6 +2116,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2094,6 +2131,7 @@ "version": "2.2.1", "bundled": true, "dev": true, + "optional": true, "requires": { "block-stream": "*", "fstream": "^1.0.2", @@ -2149,7 +2187,8 @@ "util-deprecate": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "uuid": { "version": "3.0.1", @@ -2178,7 +2217,8 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -2731,7 +2771,7 @@ } }, "lodash": { - "version": "4.17.5", + "version": "4.17.4", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", "dev": true @@ -4243,6 +4283,14 @@ "on-finished": "~2.3.0", "range-parser": "~1.2.0", "statuses": "~1.3.1" + }, + "dependencies": { + "fresh": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.0.tgz", + "integrity": "sha1-9HTKXmqSRtb9jglTz6m5yAWvp44=", + "dev": true + } } }, "serve-index": { @@ -4658,7 +4706,7 @@ } }, "url-parse": { - "version": "1.4.3", + "version": "1.1.9", "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.1.9.tgz", "integrity": "sha1-xn8dd11R8KGJEd17P/rSe7nlvRk=", "dev": true, diff --git a/src/make-vis-flexible.js b/src/make-vis-flexible.js index 706ca7305..024b5dcc1 100644 --- a/src/make-vis-flexible.js +++ b/src/make-vis-flexible.js @@ -140,8 +140,13 @@ function makeFlexible(Component, isWidthFlexible, isHeightFlexible) { this.cancelSubscription = subscribeToDebouncedResize(this._onResize); } - componentWillReceiveProps() { - this._onResize(); + componentDidUpdate(prevProps, prevState, snapshot) { + if ( + this.state.width !== prevState.width || + this.state.height !== prevState.height + ) { + this._onResize(); + } } componentWillUnmount() { diff --git a/src/plot/series/arc-series.js b/src/plot/series/arc-series.js index d50b81d65..92fee2a48 100644 --- a/src/plot/series/arc-series.js +++ b/src/plot/series/arc-series.js @@ -74,8 +74,10 @@ class ArcSeries extends AbstractSeries { this.state = {scaleProps}; } - componentWillReceiveProps(nextProps) { - this.setState({scaleProps: this._getAllScaleProps(nextProps)}); + componentDidUpdate(prevProps, prevState, snapshot) { + if (this.props !== prevProps) { + this.setState({scaleProps: this._getAllScaleProps(this.props)}); + } } /** diff --git a/src/plot/xy-plot.js b/src/plot/xy-plot.js index db47620ed..1d795884b 100644 --- a/src/plot/xy-plot.js +++ b/src/plot/xy-plot.js @@ -144,22 +144,24 @@ class XYPlot extends React.Component { }; } - componentWillReceiveProps(nextProps) { - const children = getSeriesChildren(nextProps.children); - const nextData = getStackedData(children, nextProps.stackBy); - const {scaleMixins} = this.state; - const nextScaleMixins = this._getScaleMixins(nextData, nextProps); - if ( - !checkIfMixinsAreEqual( - nextScaleMixins, - scaleMixins, - nextProps.hasTreeStructure - ) - ) { - this.setState({ - scaleMixins: nextScaleMixins, - data: nextData - }); + componentDidUpdate(prevProps, prevState, snapshot) { + if (this.props !== prevProps) { + const children = getSeriesChildren(this.props.children); + const nextData = getStackedData(children, this.props.stackBy); + const {scaleMixins} = this.state; + const nextScaleMixins = this._getScaleMixins(nextData, this.props); + if ( + !checkIfMixinsAreEqual( + nextScaleMixins, + scaleMixins, + this.props.hasTreeStructure + ) + ) { + this.setState({ + scaleMixins: nextScaleMixins, + data: nextData + }); + } } } @@ -520,12 +522,19 @@ class XYPlot extends React.Component { } render() { - const {className, dontCheckIfEmpty, style, width, height, onWheel} = this.props; + const { + className, + dontCheckIfEmpty, + style, + width, + height, + onWheel + } = this.props; if (!dontCheckIfEmpty && this._isPlotEmpty()) { return (