Next.js Image Component Not Updating Alt Text on Dynamic Props Change
I need some guidance on I'm facing an issue with the Next.js Image component where the alt text is not updating when I change the props dynamically. I have a scenario where I need to update the image source and its corresponding alt text based on user interaction. However, while the image source changes correctly, the alt text remains the same as it was on the initial render. Hereβs a simplified version of the code Iβm using: ```jsx import Image from 'next/image'; import { useState } from 'react'; const ImageSwitcher = () => { const [imageData, setImageData] = useState({ src: '/images/default.jpg', alt: 'Default Image' }); const handleImageChange = () => { setImageData({ src: '/images/new-image.jpg', alt: 'New Image Description' }); }; return ( <div> <Image src={imageData.src} alt={imageData.alt} width={500} height={300} /> <button onClick={handleImageChange}>Change Image</button> </div> ); }; export default ImageSwitcher; ``` I've tried logging the `imageData` state every time the button is clicked, and it correctly shows the new values. But when I inspect the rendered HTML, the alt attribute of the <img> tag does not update. I'm using Next.js version 13.2.4. Iβve also looked through the documentation and verified that Iβm using the Image component correctly. Is there a specific way to make sure that the alt text updates when the image source changes, or is this a known limitation in the Next.js Image component? Any insight would be greatly appreciated! My development environment is Linux. Thanks, I really appreciate it!