I'm handling file uploads using react-dropzone, which calls the following function with a list of files:
    const [files, setFiles] = useState([])
    const onDrop = useCallback(async acceptedFiles => {
        uploadFiles(acceptedFiles)
    }, [])
I then upload the files using fetch:
    const uploadFiles = async acceptedFiles => {
        acceptedFiles.forEach(async (file) => {
            setFiles(array => [...array, fileState])
            await fetch('/upload', {
                method: 'POST',
                body: data
            }).then(res => {
                // etc
            })
        })
    }
If I replace the setFiles call with just setFiles([...files, fileState]) (not in a function) it breaks, but why is this?
 
    