Skip to content

Commit

Permalink
Upgrade to React 17 (#1473)
Browse files Browse the repository at this point in the history
Signed-off-by: Sergio-Mira <sergio.mira@zendesk.com>
  • Loading branch information
Sergio-Mira authored Sep 9, 2024
1 parent 399fe4e commit fe9794c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
8 changes: 4 additions & 4 deletions packages/react-vis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@
"jsdom": "^9.9.1",
"node-sass": "^4.9.3",
"prettier": "^1.14.2",
"react": "^16.0.0",
"react": "^17.0.2",
"react-addons-test-utils": ">=15.4.2",
"react-dom": "^16.0.0",
"react-dom": "^17.0.2",
"react-test-renderer": "^16.13.1",
"react-vis-showcase": "^0.1.0",
"regenerator-runtime": "^0.13.11",
Expand All @@ -88,8 +88,8 @@
"uglify-js": "^2.8.22"
},
"peerDependencies": {
"react": "^16.8.3",
"react-dom": "^16.8.3"
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"keywords": [
"d3",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-vis/src/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Animation extends PureComponent {
this._updateInterpolator(props);
}

UNSAFE_componentWillUpdate(props) {
componentDidUpdate(props) {
this._updateInterpolator(this.props, props);
if (props.onStart) {
props.onStart();
Expand Down
18 changes: 10 additions & 8 deletions packages/react-vis/src/plot/xy-plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,28 +139,30 @@ class XYPlot extends React.Component {
const children = getSeriesChildren(props.children);
const data = getStackedData(children, stackBy);
this.state = {
scaleMixins: this._getScaleMixins(data, props),
scaleMixins: XYPlot._getScaleMixins(data, props),
data
};
}

UNSAFE_componentWillReceiveProps(nextProps) {
static getDerivedStateFromProps(nextProps) {
const children = getSeriesChildren(nextProps.children);
const nextData = getStackedData(children, nextProps.stackBy);
const {scaleMixins} = this.state;
const nextScaleMixins = this._getScaleMixins(nextData, nextProps);
const nextScaleMixins = XYPlot._getScaleMixins(nextData, nextProps);
if (
!checkIfMixinsAreEqual(
nextScaleMixins,
scaleMixins,
nextProps.hasTreeStructure
)
) {
this.setState({
return {
scaleMixins: nextScaleMixins,
data: nextData
});
};
}

return null;
}

/**
Expand Down Expand Up @@ -231,7 +233,7 @@ class XYPlot extends React.Component {
* @returns {Object} Defaults.
* @private
*/
_getDefaultScaleProps(props) {
static _getDefaultScaleProps(props) {
const {innerWidth, innerHeight} = getInnerDimensions(
props,
DEFAULT_MARGINS
Expand Down Expand Up @@ -262,11 +264,11 @@ class XYPlot extends React.Component {
* @returns {Object} Map of scale-related props.
* @private
*/
_getScaleMixins(data, props) {
static _getScaleMixins(data, props) {
const filteredData = data.filter(d => d);
const allData = [].concat(...filteredData);

const defaultScaleProps = this._getDefaultScaleProps(props);
const defaultScaleProps = XYPlot._getDefaultScaleProps(props);
const optionalScaleProps = getOptionalScaleProps(props);
const userScaleProps = extractScalePropsFromProps(props, ATTRIBUTES);
const missingScaleProps = getMissingScaleProps(
Expand Down
4 changes: 2 additions & 2 deletions packages/showcase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"dependencies": {
"d3-force": "^1.0.6",
"d3-random": "^1.1.0",
"react": "^16.8.3",
"react-dom": "^16.8.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-vis": "^1.11.7"
Expand Down

0 comments on commit fe9794c

Please sign in to comment.