question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`interpolate` not backwards compatible with [0,0] range

See original GitHub issue

Hello! 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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:9

github_iconTop GitHub Comments

1reaction
raimonkhcommented, Sep 12, 2019

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

1reaction
kristfalcommented, Jun 11, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

scipy.interpolate.spline not working as intended - Stack Overflow
Under additional tools, scipy lists spline as: Functions existing for backward compatibility (should not be used in new code):.
Read more >
How to Interpolate in Excel: 4 simple ways
In this post, we look at how we can interpolate in Excel with 5 ... for the purpose of backward compatibility with Excel...
Read more >
Interpolation (scipy.interpolate) — SciPy v1.9.3 Manual
Convenience function for polynomial interpolation. ... pchip is an alias of PchipInterpolator for backward compatibility (should not be used in new code).
Read more >
interp: Interpolation Methods
Details This function is a call wrapper for backward compatibility with package akima.
Read more >
warning messages - SystemException with Interpolation
This syntax was deprecated a long time ago, but is still accepted for backward compatibility (see also the legacy reference page).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found