react-native-reanimated: [3.0.0-rc.0] Cannot read property 'CLAMP' of undefined
Description
Cannot read property 'CLAMP' of undefined when using Extrapolate.CLAMP
Actual behavior & steps to reproduce
Upgrade to v3 rc0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 16 (2 by maintainers)
There may be a namespacing or typing issue with
Animated.Extrapolate. Typescript thinks it’s an enum but it’s actually defined as an object. Meanwhile,Extrapolationfrom theinterpolationmodule is an enum.Put this at the top of index.js
Same here, but in tests with jest
Upgrade to react-native-redash 17.0.0 has fixed this issue in my case (forcing this version in resolutions for bottom-sheet)
I’m not sure either, but enums are more complicated than just being compiled to JS objects.
interpolation.tsexports an enum calledExtrapolation, which is rarely if ever used by libraries or end users. Most of us prefer toimport { Extrapolate } from "react-native-reanimated"interpolateColor.tsexports an object calledExtrapolatewith the same properties and values as theenum Extrapolation.Both of these are exported (https://github.com/software-mansion/react-native-reanimated/blob/main/src/reanimated2/index.ts)
Meanwhile
react-native-reanimated.d.tsexports an enum calledExtrapolate.I don’t understand how (or even if) this is causing the error, or the best way to fix it, but adding
Animated.Extrapolate = Extrapolationat the top of myindex.jsseems to be a temporary workaround.