I am facing a really odd problem which causes feel like "whatever you cal"
First of all here is the code:
renderImages = () => {
let i = 0;
const arr = [
"https://truffle-assets.imgix.net/pxqrocxwsjcc_6OcJeUMaWIYOmKgsK6IwWc_galaxy-cupcakes_squareThumbnail_en-US.jpeg",
"https://sallysbakingaddiction.com/wp-content/uploads/2017/06/moist-chocolate-cupcakes-5.jpg",
"http://is4.mzstatic.com/image/thumb/Purple127/v4/74/47/31/7447317e-9844-3ee0-d189-661a55c94abe/source/1200x630bb.jpg",
"https://i.pinimg.com/736x/55/03/94/550394c428e268868aa73e509302b84c--neopolitan-cupcakes-ice-cream-cupcakes.jpg"
];
return arr.map((item) => {
i++;
return(
<div>
<img src={item} onClick={() => alert(i)} alt={i} />
</div>
);
})
};
Now when i click on an image, it always shows 4. First image shows 4 and last image shows 4. All of them alerts 4. However, their alt tag seems correct. I don't think i am doing something wrong but i am :)
My react version is 16.1.1
So anyone know what am i doing wrong here? I don't think it is a bind problem but who knows.