The bug it's setGalleryImg(`img${e.target.id}`);
That sets the state to the literal string "img1" / "img2"… not to the imported image module (img1, img2, etc.). As a result, React tries to load a URL literally called img1, which doesn’t exist, so the image “disappears”.
Use the useEffect to log your useState