From 87ef6ac735c23772262066de8b2644e0c177164e Mon Sep 17 00:00:00 2001 From: Valentin Hervieu Date: Thu, 27 Nov 2025 09:28:16 +0100 Subject: [PATCH] fix: prevent NaN crop when previousCropSize.x/y is zero --- src/Cropper.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cropper.tsx b/src/Cropper.tsx index 3933fc1..52e7677 100644 --- a/src/Cropper.tsx +++ b/src/Cropper.tsx @@ -734,7 +734,7 @@ class Cropper extends React.Component { let adjustedCrop = this.props.crop // Only scale if we're initialized and this is a legitimate resize - if (this.isInitialized && this.previousCropSize) { + if (this.isInitialized && this.previousCropSize?.width && this.previousCropSize?.height) { const sizeChanged = Math.abs(this.previousCropSize.width - this.state.cropSize.width) > 1e-6 || Math.abs(this.previousCropSize.height - this.state.cropSize.height) > 1e-6