benhowell/react-grid-gallery

Gallery is static

Opened this issue · 2 comments

Expected behaviour

when change the size, image is resized

Actual behaviour

when change the size, nothing happens

Steps to reproduce behaviour

import { Gallery } from "react-grid-gallery";
import Lightbox from "react-image-lightbox";
import { Image as IImage } from "react-grid-gallery";
export function GalleryShow({ images }: { images: Partial<GalleryImageItem>[] }) {
  const [index, setIndex] = useState(-1);
  const [size, setSize] = useState(120);

  const currentImage = images[index];
  const nextIndex = (index + 1) % images.length;
  const nextImage = images[nextIndex] || currentImage;
  const prevIndex = (index + images.length - 1) % images.length;
  const prevImage = images[prevIndex] || currentImage;

  const handleClick = (index: number, item: CustomImage) => setIndex(index);
  const handleClose = () => setIndex(-1);
  const handleMovePrev = () => setIndex(prevIndex);
  const handleMoveNext = () => setIndex(nextIndex);
  let DATA = images.map(e => { return { ...e, width: size, height: size } })
  useEffect(() => {
    DATA = images.map(e => { return { ...e, width: size, height: size } })
    console.log(DATA)
  }, [size])

  return (
    <div>
      <input type="range" min={20} defaultValue={size} max={400} step={20} onChange={(e) => { setSize(parseInt(e.currentTarget.value, 10)) }} />
      <Gallery images={DATA as GalleryImageItem[]} onClick={handleClick} enableImageSelection={false} />
      {!!currentImage && (
        <Lightbox mainSrc={currentImage.original!} imageTitle={currentImage.caption} mainSrcThumbnail={currentImage.src} nextSrc={nextImage.original!} nextSrcThumbnail={nextImage.src!}
          prevSrc={prevImage.original!} prevSrcThumbnail={prevImage.src!} onCloseRequest={handleClose} onMovePrevRequest={handleMovePrev} onMoveNextRequest={handleMoveNext}
        />
      )}
    </div>
  );
}
``` link the css too
### Operating system
windows 11
### Browser and version
Mozilla - latest
### Hardware

Hey @c0ncentus, I just published a new version react-grid-gallery@1.0.1. Can you try again, please?

the same issue (my data is updated via console.log and I checked that). the ui seems static