Image Selection
const [images, setImages] = useState(IMAGES);
const handleSelect = (index: number, item: Image, event: MouseEvent<HTMLElement>) => {
const nextImages = images.map((image, i) =>
i === index ? { ...image, isSelected: !image.isSelected } : image
);
setImages(nextImages);
};
return (
<Gallery images={images} onSelect={handleSelect} />
)
Live Demo
Source Code
react-grid-gallery/examples/selection (opens in a new tab)