We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
croppedImage doesn't generate path and preview so I do rewrite some code with better type guard using satisfies
const onCrop = React.useCallback(() => { if (!files || !cropperRef.current) return setCropData(cropperRef.current?.cropper.getCroppedCanvas().toDataURL()) cropperRef.current?.cropper.getCroppedCanvas().toBlob((blob) => { if (!blob) return const croppedImage = new File([blob], file.name, { type: file.type, lastModified: Date.now(), }) files.splice(i, 1, croppedImage as FileWithPreview) setValue(name, files as PathValue<TFieldValues, Path<TFieldValues>>) }) }, [file.name, file.type, files, i, name, setValue])
const onCrop = React.useCallback(() => { if (!files || !cropperRef.current) return const croppedCanvas = cropperRef.current?.cropper.getCroppedCanvas() setCropData(croppedCanvas.toDataURL()) croppedCanvas.toBlob((blob) => { if (!blob) { console.error("Blob creation failed") return } const croppedImage = new File([blob], file.name, { type: file.type, lastModified: Date.now(), }) const croppedFile = Object.assign(croppedImage, { preview: URL.createObjectURL(croppedImage), path: file.name, }) satisfies FileWithPreview const newFiles = [...files] newFiles.splice(i, 1, croppedFile) setValue(name, newFiles as PathValue<TFieldValues, Path<TFieldValues>>) }) }, [file.name, file.type, files, i, name, setValue])
The text was updated successfully, but these errors were encountered:
No branches or pull requests
croppedImage doesn't generate path and preview so I do rewrite some code with better type guard using satisfies
The text was updated successfully, but these errors were encountered: