I have a product tile component which accepts an imageSrc prop. Whenever the imageSrc prop is updated, I want the old image to fade out as the new image is fading in. With my current implementation, the animation does not work. I can confirm that the imageSrc is updating properly, however the image updates instantly with no animation. How can I get this animation to work?
const imageTransition = useTransition(imageSrc, item => item.key, {
from: {
opacity: 0,
width: "100%",
},
enter: {
opacity: 1,
},
leave: {
opacity: 0
},
});
{imageTransition.map(({ item, props, key }) => (
<animated.img style={props} key={key} src={imageSrc}></animated.img>
))}