Skip to content
Discussion options

You must be logged in to vote

Yes, File Upload works standalone (no form required). Consider using transformFiles in your code for opening an image
cropper before accepting files.

When files are selected, transformFiles runs before they're added to acceptedFiles. This means you can:

  1. Open your image cropper modal
  2. Wait for the user to finish cropping
  3. Return the cropped files
  4. Only then will they appear in the component

Here's what that looks like:

function ImageUploadWithCropper() {
  const [openCropper, setOpenCropper] = useState(false)
  const [currentFile, setCurrentFile] = useState<File | null>(null)

  const [state, send] = useMachine(
    fileUpload.machine({
      id: useId(),
      transformFiles: async (files) =>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@warm-tune
Comment options

Answer selected by segunadebayo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants