Open lettertwo opened 10 years ago
Maybe we can circumvent the issue by inspecting the tween instance when the plugin initializes, and look for the immediateRender
flag. If it's present, we pull the start values from component.state
instead of tweenState
.
Because state changes in React components can be asynchronous, the plugin has to track a proxy for the component state so that multiple tweens can act in between component updates.
But, because the component doesn't know about this proxy, there is no way for the tweens to know when the state is changed outside of the tweening process. For example:
There doesn't seem to be any good options for solving this.
Here are some bad ones:
target.state
directly (instead of maintaining an separate tween state and binding them together)componentShouldUpdate
andcomponentDidUpdate
, when comparisons between previous and next tween states are inaccurate (since the state gets mutated directly between renders by the tween)target.setState
to make sure it also updates the tween statesetTweenState
method to the component that can update the tween proxy object and callsetState
setState
(or at least everywhere that the component would want to update state that is also being tweened)