Reactjs – React showing previous state ,only updates on refreshing
I am developing an ecommerce application and on productdetail page my main image is showing previous state ..only updates on refreshing page const [mainImage,setMainImage] = useState(images[0]) return ( <div className="productdisplay-img-left"> {(images.length > 1) && ( images.map((image,index)=>( <img key={index} onClick={()=>setMainImage(image)} src={`http://localhost:3000/public/products/${image}`}/>…