This is my interface
interface FloatingLabelState {
paddingAnim: Animated.Value;
opacityAnim: Animated.Value;
useNativeDriver :boolean;
}
This is my componentWillReceiveProps function
componentWillReceiveProps(newProps: FloatingLabelProps) {
Animated.timing(this.state.paddingAnim, {
toValue: newProps.visible ? 5 : 9,
duration: 230,
useNativeDriver:this.state.useNativeDriver
}).start();
return Animated.timing(this.state.opacityAnim, {
toValue: newProps.visible ? 1 : 0,
duration: 230,
useNativeDriver:this.state.useNativeDriver
}).start();
}
With many resources, came to know that static getDerivedStateFromProps() would be an alternative, Can someone help me convert componentWillReceiveProps to getDerivedStateFromProps method.