interpolateColor ERROR: Cannot read property 'exec' of undefined
See original GitHub issueDescription
Trying to animate background color, but got error Cannot read property ‘exec’ of undefined. Also tried to wrap return value of backgroundColor into processColor function but got the same result
Code example:
import React, {memo, useMemo, useCallback} from 'react';
import {StyleSheet} from 'react-native';
import Animated, {
useSharedValue,
useDerivedValue,
useAnimatedStyle,
withTiming,
interpolateColor,
} from 'react-native-reanimated';
import {TouchableWithoutFeedback} from 'react-native-gesture-handler';
const ENABLED_POSITION = 20;
export const Thumbler = memo(() => {
const x = useSharedValue(ENABLED_POSITION);
const enabled = useSharedValue(0);
const translateX = useDerivedValue(() => x.value * enabled.value);
const onPress = useCallback(() => {
enabled.value = withTiming(1, {duration: 100});
}, []);
const backgroundColor = useDerivedValue(() => {
return interpolateColor(enabled.value, [0, 1], ['#333333', '#666999']);
});
const useIndicatorStyle = useAnimatedStyle(() => ({
transform: [{translateX: translateX.value}],
}));
const useThumblerStyle = useAnimatedStyle(() => ({
backgroundColor: backgroundColor.value,
}));
const indicatorStyle = useMemo(
() => [styles.indicator, useIndicatorStyle],
[useIndicatorStyle],
);
const thumblerStyle = useMemo(() => [styles.thumbler, useThumblerStyle], [
useThumblerStyle,
]);
return (
<TouchableWithoutFeedback onPress={onPress} style={styles.touchable}>
<Animated.View style={thumblerStyle}>
<Animated.View style={indicatorStyle} />
</Animated.View>
</TouchableWithoutFeedback>
);
});
const styles = StyleSheet.create({
touchable: {
height: 20,
width: 38,
justifyContent: 'center',
alignItems: 'center',
},
thumbler: {
width: 36,
height: 18,
borderRadius: 9,
},
indicator: {
width: 18,
height: 18,
borderRadius: 20,
backgroundColor: '#ddd',
},
});
Package versions:
- React Native: 0.63.3
- React Native Reanimated: 2.0.0-alpha.9.1
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:9 (4 by maintainers)
Top Results From Across the Web
TypeError: Cannot read property 'exec' of undefined
I am new to Electron Framework and I am trying out an application where I need to launch a particular software (e.g. firefox)...
Read more >interpolateColors | React Native Reanimated
This is documentation for React Native Reanimated 1.x.x, which is no longer actively maintained. For up-to-date documentation, see the latest version (2.5.x – ......
Read more >Getting the same error (Cannot read property 'execute ... - Reddit
The error message means that client.commands.get('ping') is returning undefined, so it doesn't have an execute method to invoke.
Read more >exec nodejs Code Example
const { exec } = require('child_process'); const cmd = 'scp ... if (error !== null) { ... TypeError: Cannot read property 'version' of...
Read more >Index (JavaFX 8) - Oracle Help Center
This method is called from CSS code to set the value of the property. ... Retrieve the value of the error property or...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yes, It’s possible, because we haven’t been releasing a new version with this patch. We try to release a new version every two week - it should happen on Thursday or Friday.
@caiphaav I can confirm that this bug exists in my project too.