I need help in image cropping plugin. react-image-crop

I am using the react-image-crop react-image-crop - npm This react pakage in my project. well. all functionality are working but when croped image and generate an image object was not update in react state Please any one can suggest the solution.
following is my function that called when i click save button

const onCropChange = async(crop, percentCrop)=>{
      setCrop(percentCrop);
      // setCompletedCrop(percentCrop);
      const image = imgRef.current
      // console.log("imgRef",imgRef)
      const previewCanvas = previewCanvasRef.current
      console.log("previewCanvas ",previewCanvas,completedCrop)
      if (!image || !previewCanvas || !completedCrop) {
        throw new Error('Crop canvas does not exist')
      }

      // This will size relative to the uploaded image
      // size. If you want to size according to what they
      // are looking at on screen, remove scaleX + scaleY
      const scaleX = image.naturalWidth / image.width
      const scaleY = image.naturalHeight / image.height
    
      const offscreen = new OffscreenCanvas(
        completedCrop.width * scaleX,
        completedCrop.height * scaleY,
      )
     
      const ctx = offscreen.getContext('2d');
 
      if (!ctx) {
        throw new Error('No 2d context')
      }

      ctx.drawImage(
        previewCanvas,
        0,
        0,
        previewCanvas.width,
        previewCanvas.height,
        0,
        0,
        offscreen.width,
        offscreen.height,
      )
      // You might want { type: "image/jpeg", quality: <0 to 1> } to
      // reduce image size
      const blob = await offscreen.convertToBlob({
        type: 'image/png',
      })

      if (blobUrlRef.current) {
        URL.revokeObjectURL(blobUrlRef.current)
      }
      blobUrlRef.current = URL.createObjectURL(blob);
      console.log("url generated ...",typeof blobUrlRef.current);
      setCroppedImageUrl(blobUrlRef.current);  // Here i set the state
      if (hiddenAnchorRef.current) {
        hiddenAnchorRef.current.href = blobUrlRef.current
        hiddenAnchorRef.current.click()
      }
      
    }