`interpolate` not backwards compatible with [0,0] range
See original GitHub issueHello! Thanks for this library - it seems like it’s going to be a big improvement over the old Animated
.
I’m trying to upgrade an app to RN 0.59, which via react-navigation
and react-navigation-tabs
has necessitated upgrading to this library. I’m getting a whole lot of NaN
from what I was expecting to be backwards compatible calls (from README: “Use the same Animated library API from React Native that you’ve been using. You don’t need to change anything.”). For example, the interpolate example from the release notes:
# Old API
> a = new OldAnimated.Value(4)
> a._value
4
> a.__getValue()
4
> c = a.interpolate({inputRange: [0, 10], outputRange: [10, 20], extrapolate: 'clamp'})
AnimatedInterpolation {_children: Array(0), _parent: AnimatedValue, _config: Object, _interpolation: function}
> c._value
undefined
> c.__getValue()
14
# New API
> b = new Animated.Value(5)
> b._value
5
> b.__getValue()
NaN
> d = Animated.interpolate(b, {inputRange: [0, 10], outputRange: [10, 20], extrapolate: 'clamp'})
AnimatedCond {__lastLoopID: 0, __memoizedValue: null, __children: Array(0), __nodeID: 7266, __nodeConfig: Object…}
> d._value
undefined
> d.__getValue()
NaN
(I’m not sure which of _value
or __getValue()
is supposed to be the same, I can’t find public API clearly documented, but this does seem to be causing my issue.)
I’ve also noticed similar disparities in other functions, such as return value of Animated.subtract
.
This leads to hard to track down bugs, since the NaN
value often gets all the way into native code and gives no stack trace as to where it originated.
What is the intended scope of backwards compatibility here? Am I doing it wrong?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9
Top GitHub Comments
Dirty solution, you can interpolate from 0 to 0.01… so basically never interpolate to the same number but to a fraction of it close to 0… that fixed our problems
This may be caused by an issue related to a subset of Android 9 devices when you’re building with SDK tools 28. You likely bumped to 28 while upgrading to RN59, which could be the issue, and not this lib in itself.
Please have a look at: https://github.com/n4kz/react-native-indicators/issues/22 https://github.com/react-native-community/react-native-tab-view/issues/715
Could you see if you can answer a few of the test cases?
Thanks