-
Notifications
You must be signed in to change notification settings - Fork 70
Change from React 0.12 to 0.13
Cheng Lou edited this page Jun 22, 2015
·
4 revisions
React 0.13 brings several changes, one of which affects tween-state in a subtle way.
Previously, setState
might or might not have been synchronous. Under 0.12:
// assume initial state of {a: 0}
this.setState({a: 10});
this.tweenState('a', {endValue: 20});
The expectation is that tweenState correctly deduce the beginValue
of 10. It did: it read into the component's internal _pendingState
if there is any, and used that as the beginValue
. Though you really shouldn't have had that expectation. The correct way would be this.setState({a: 10}, () => this.tweenState('a', {endValue: 20}))
.
Same category, but more relevant example:
// assume initial state of {a: 0}
this.tweenState('a', {endValue: 10});
this.tweenState('a', {endValue: 20}); // why are you doing this though
Under React 0.12: from 0 to 20 (tween-state <= 0.0.5).
Under React 0.13: from 10 to 20 (tween-state >= 1.0.1).