@@ -8,10 +8,6 @@ import { connect } from 'react-redux';
88import { VictoryAnimation } from 'victory-core' ;
99import { victoryEases } from '../utils/types' ;
1010
11- // TODO(540): Refactor to non-deprecated lifecycle methods.
12- // https://github.com/FormidableLabs/spectacle/issues/540
13- // - componentWillReceiveProps
14- // eslint-disable-next-line react/no-deprecated
1511class Anim extends Component {
1612 state = {
1713 activeAnimation : - 1
@@ -36,29 +32,32 @@ class Anim extends Component {
3632 node . dataset . animCount = this . props . toStyle . length ;
3733 }
3834
39- componentWillReceiveProps ( nextProps ) {
35+ componentDidUpdate ( prevProps , prevState ) {
4036 const shouldDisableAnimation =
41- nextProps . route . params . indexOf ( 'export' ) !== - 1 ||
42- nextProps . route . params . indexOf ( 'overview' ) !== - 1 ;
37+ this . props . route . params . indexOf ( 'export' ) !== - 1 ||
38+ this . props . route . params . indexOf ( 'overview' ) !== - 1 ;
4339
4440 if ( shouldDisableAnimation ) {
41+ // setState in componentDidUpdate OK if wrapped in a condition according to docs
42+ // eslint-disable-next-line react/no-did-update-set-state
4543 this . setState ( { activeAnimation : this . props . toStyle . length - 1 } ) ;
46- return ;
4744 }
4845
4946 const animationStatus = this . getAnimationStatus ( ) ;
5047 if ( animationStatus ) {
5148 const nextAnimation = animationStatus . every ( a => a === true )
5249 ? animationStatus . length - 1
5350 : animationStatus . indexOf ( false ) - 1 ;
54- if ( this . state . activeAnimation !== nextAnimation ) {
55- const state = nextProps . fragment ;
56- const { slide } = this . props . route ;
51+ if ( prevState . activeAnimation !== nextAnimation ) {
52+ const state = this . props . fragment ;
53+ const { slide } = prevProps . route ;
5754 this . context . stepCounter . setFragments ( state . fragments [ slide ] , slide ) ;
58- if ( this . props . onAnim ) {
59- const forward = this . state . activeAnimation < nextAnimation ;
60- this . props . onAnim ( forward , nextAnimation ) ;
55+ if ( prevProps . onAnim ) {
56+ const forward = prevState . activeAnimation < nextAnimation ;
57+ prevProps . onAnim ( forward , nextAnimation ) ;
6158 }
59+ // setState in componentDidUpdate OK if wrapped in a condition according to docs
60+ // eslint-disable-next-line react/no-did-update-set-state
6261 this . setState ( {
6362 activeAnimation : nextAnimation
6463 } ) ;
0 commit comments