I use useAnimatedStyle with interpolateColor, it's make exception

const Dot: React.FC<{
index: number;
currentIndex: Animated.SharedValue<number>;
}> = ({ index, currentIndex }) => {
const style = useAnimatedStyle(() => {
return {
backgroundColor: interpolateColor(
currentIndex.value,
[index - 1, index, index + 1],
["#DDE2E9", "#ABB5C4", "#DDE2E9"],
),
};
});
return (
<Animated.View
style={[
{
width: 10,
height: 10,
borderRadius: 10,
},
style,
]}
/>
);
};
This is either a new regression or we have to start processing colours differently, this does not happen in alpha 7 but does in 8.
try this with processColor function exported from 'react-native'.
example: https://github.com/software-mansion/react-native-reanimated/issues/1053#issue-669587466
Hey @vamshi9666 I'll have a check but pretty sure I have been, had a few animated colour components in alpha 7 that used processColor from react-native that now throw this error in 8.
Hi!
This worked for me without any problems.
Have you tried yarn start --reset-cache after upgrading reanimated version?
@vamshi9666 processColor in reanimated is more or less a workletized version of RN's processColor so if you work on UI thread(like in useAnimatedStyle) you should go for reanimated's version.
Hi @karol-bisztyga
I just reinstall with the latest build and it's still like that. I use console but this line always get an empty object
Hi @hoangtrucit
I tried to reproduce your issue but I wasn鈥檛 able to do this because it worked for me also. I think that the problem may be in other related components.
Could you give me more example code or a link to a repository?
Could you also show me the rest of errors? - because on screenshots there is more than one error.
just for sure you can run: npm cache clean --force
Hey I'll try to free up some time and help out here with replication, side project wise interpolating colours is a priority of mine.
this issue is resolved with version 2.0.9
@hoangtrucit is there a 2.0.9 version ?
I think that it mean 2.0.0-alpha.9 but today we released new version 2.0.0-rc.1 and I recommend use newer version.
I still get this error and I am using 2.0.0-rc.0
if I do the following:
```
const colors = useAnimatedProps(() => {
const color1 = interpolateColor(
graphHeiht.value,
[0, 1, 2, 3, 4, 5],
['#A1D2CE', '#78CAD2', '#62A8AC', '#5497A7', '#50858B', '#BBB09B']
);
const color2 = interpolateColor(
graphHeiht.value,
[0, 1, 2, 3, 4, 5],
['#A1D2CE', '#78CAD2', '#62A8AC', '#5497A7', '#50858B', '#BBB09B']
);
return [color1, color2];
});
```
@mhjey Try to use 2.0.0-rc.1 because I fixed this in PR: #1504
Most helpful comment
this issue is resolved with version 2.0.9