diff --git a/src/view/addProduct/components/addPic.js b/src/view/addProduct/components/addPic.js index e5227c8..2e049b0 100644 --- a/src/view/addProduct/components/addPic.js +++ b/src/view/addProduct/components/addPic.js @@ -6,6 +6,7 @@ const AddPic = () => { const [selectedImage, setSelectedImage] = useState(null); const [fakeState, setFakeState] = useState(5); const [deleteFirst, setDeleteFirst] = useState(false) + const [deleteImage, setDeleteImage] = useState(null); useEffect(() => { if (selectedImage) { @@ -42,7 +43,19 @@ const AddPic = () => {
{ imageUrl.slice(1,imageUrl.length).map((item, index) => ( +
{setDeleteImage(index); console.log(index)}} + onMouseLeave={() => setDeleteImage(null)} + > + { + deleteImage == index &&
+ { + let newImageArray = imageUrl.filter((itm, idx) => idx !== index + 1); + setImageUrl(newImageArray) + }}/> +
+ } +
)) }