I'm trying to animate the color of header back button from color grey background with white arrow icon to color white background with black arrow icon in react native react navigation 5.
I tried to do the following, but it is throwing RangeError: Maximum call stack size exceeded.
const yOffset = useRef(new Animated.Value(0)).current;
const backButtonBackgroundColorAnimation = yOffset.interpolate({
inputRange: [0, 130],
outputRange: ['rgba(0,0,0,0.4)', 'rgba(0,0,0,0)'], // gray transparent to transparent
extrapolate: "clamp"
});
const backArrowColorAnimation = yOffset.interpolate({
inputRange: [0, 130],
outputRange: ['rgb(255,255,255)', 'rgb(0,0,0)'], // white to black
extrapolate: "clamp"
});
import {Icon} from 'react-native-elements';
headerLeft: (props) => (
<Animated.View style={{backgroundColor: backButtonOpacity}} >
<Icon
name='arrowleft'
type='antdesign'
color='white'
size={24}
containerStyle={{ backgroundColor:backButtonBackgroundColorAnimation, color:backArrowColorAnimation, borderRadius:500, padding: 5, marginLeft:10}}
{...props}
onPress={() => {
navigation.goBack();
}}
/>
</Animated.View>
)
<Animated.ScrollView
onScroll={Animated.event(
[
{
nativeEvent: {
contentOffset: {
y: yOffset,
},
},
},
],
{ useNativeDriver: false }
)}
scrollEventThrottle={16}
>

