sekoyo / react-image-crop

A responsive image cropping tool for React
ISC License
3.85k stars 344 forks source link

The previous image layout still be kept after switch image #585

Open daFoggo opened 6 months ago

daFoggo commented 6 months ago

Hi. I'm currently having this issues. Can someone help me please? https://github.com/sekoyo/react-image-crop/assets/108665939/7fa65ecb-112a-435a-939f-74d7bfb60707

bodryi commented 2 months ago

@daFoggo Hello! As a workaround, you can add unique key to ReactCrop component, so it will rerender every time your image updates.

<ReactCrop
  key={uniqueImageKey}
  circularCrop
  keepSelection
  crop={crop}
  aspect={1}
  minWidth={50}
  onChange={(_, percentCrop) => setCrop(percentCrop)}
  onComplete={(c) => setCompletedCrop(c)}
>
   {/* Your image */}
</ReactCrop>

Possibly the problem is with rect in svg def. It has width and height 100% and it doesn't update visually when image dimensions are changed.