From c91c0da8a7dbdeb00dc8789211192c3add51ee38 Mon Sep 17 00:00:00 2001 From: Graham McGregor Date: Sat, 22 Jul 2017 16:49:49 -0400 Subject: [PATCH] Update to React 15.6 Once we're upgraded to React 15.x and have no deprecation warnings, upgrading to React 16 should be painless. PureRenderMixin has been superceded by PureComponent. According to the docs PureComponent should only be used if all of it's children are also "pure". https://facebook.github.io/react/docs/react-api.html#react.purecomponent --- app/scripts/views/pie_chart.js | 6 ++---- app/scripts/views/rhythm_settings_view.js | 2 -- app/scripts/views/rhythm_statistic_view.js | 2 -- app/scripts/views/stave_renderer.js | 8 +++----- package.json | 5 ++--- 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/app/scripts/views/pie_chart.js b/app/scripts/views/pie_chart.js index 5f24d3e..fa06d0f 100644 --- a/app/scripts/views/pie_chart.js +++ b/app/scripts/views/pie_chart.js @@ -1,15 +1,13 @@ import Chartist from "Chartist"; -import React, { Component } from "react"; -import PureRenderMixin from "react-addons-pure-render-mixin"; +import React, { PureComponent } from "react"; -export default class LevelView extends Component { +export default class LevelView extends PureComponent { static propTypes = { pieParts: React.PropTypes.array.isRequired }; constructor(props, context) { super(props, context); - this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this); } render() { diff --git a/app/scripts/views/rhythm_settings_view.js b/app/scripts/views/rhythm_settings_view.js index dfcac1a..6b8ee28 100644 --- a/app/scripts/views/rhythm_settings_view.js +++ b/app/scripts/views/rhythm_settings_view.js @@ -1,5 +1,4 @@ import React, { Component } from "react"; -import PureRenderMixin from "react-addons-pure-render-mixin"; import RangeSettingComponent from "./range_setting_component"; import SettingLine from "./setting_line"; import AnalyticsService from "../services/analytics_service.js"; @@ -12,7 +11,6 @@ export default class PitchSettingsView extends Component { constructor(props, context) { super(props, context); - this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this); } buildStateChanger(stateKey) { diff --git a/app/scripts/views/rhythm_statistic_view.js b/app/scripts/views/rhythm_statistic_view.js index e6a71e9..d7c6d04 100644 --- a/app/scripts/views/rhythm_statistic_view.js +++ b/app/scripts/views/rhythm_statistic_view.js @@ -5,7 +5,6 @@ import _ from "lodash"; import AnimatedNumber from "./animated_number.js"; import StarAnimation from "./star_animation.js"; -import PureRenderMixin from "react-addons-pure-render-mixin"; export default class RhythmStatisticView extends Component { static propTypes = { @@ -14,7 +13,6 @@ export default class RhythmStatisticView extends Component { constructor(props) { super(props); - this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this); } getHumanReadableTime(milliseconds) { diff --git a/app/scripts/views/stave_renderer.js b/app/scripts/views/stave_renderer.js index 36a2fc5..187f3ff 100644 --- a/app/scripts/views/stave_renderer.js +++ b/app/scripts/views/stave_renderer.js @@ -1,15 +1,14 @@ import Vex from "vexflow"; -import React, { Component } from "react"; +import React, { PureComponent } from "react"; import _ from "lodash"; -import PureRenderMixin from "react-addons-pure-render-mixin"; -class StaveRenderer extends Component { +class StaveRenderer extends PureComponent { static defaultProps = { staveCount: 2 }; static propTypes = { - keys: React.PropTypes.array, + keys: React.PropTypes.objectOf(React.PropTypes.array), chordIndex: React.PropTypes.number, keySignature: React.PropTypes.string, staveCount: React.PropTypes.number @@ -17,7 +16,6 @@ class StaveRenderer extends Component { constructor(props) { super(props); - this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this); } render() { diff --git a/package.json b/package.json index 0bc0002..5115b8b 100644 --- a/package.json +++ b/package.json @@ -21,10 +21,9 @@ "freezer-js": "git+https://github.com/philippotto/freezer.git#native-object-handling-build", "html-loader": "^0.4.3", "lodash": "^4.5.1", - "react": "^0.14.5", - "react-addons-pure-render-mixin": "^0.14.8", + "react": "^15.6.1", "react-bootstrap": "^0.28.3", - "react-dom": "^0.14.5", + "react-dom": "^15.6.1", "react-motion": "^0.4.2", "react-range-slider-bem": "^0.2.11", "vexflow": "^1.2.41"