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.

interpolateColor ERROR: Cannot read property 'exec' of undefined

See original GitHub issue

Description

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:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
piaskowykcommented, Dec 14, 2020

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.

1reaction
AlexeyVlasenkocommented, Nov 24, 2020

@caiphaav I can confirm that this bug exists in my project too.

Read more comments on GitHub >

github_iconTop 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 >

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