I want to use react-dropzone-uploader to choose image file and then upload it to my php server (codeigniter 4, if it matters). but even though I already defined xhr in the parameters, it gives an error xhr is undefined. why is that?
here's my code: codesandbox
import React from "react";
import "react-dropzone-uploader/dist/styles.css";
import Dropzone from "react-dropzone-uploader";
import "./styles.css";
export default function App() {
const toast = (innerHTML) => {
const el = document.getElementById("toast");
el.innerHTML = innerHTML;
el.className = "show";
setTimeout(() => {
el.className = el.className.replace("show", "");
}, 3000);
};
const handleChangeStatus = ({ meta, file, xhr }, status) => {
console.log("handlechangestatus", status, meta, file);
if (status === "done") {
console.log('xhr', xhr);
let response = JSON.parse(xhr.response);
}
};
return (
<div className="App">
<h1>Hello CodeSandbox</h1>
<React.Fragment>
<div id="toast">Upload</div>
<Dropzone
// getUploadParams={getUploadParams}
onChangeStatus={handleChangeStatus}
maxFiles={1}
multiple={false}
canCancel={false}
inputContent="Drop A File"
styles={{
dropzone: { height: 200 },
dropzoneActive: { borderColor: "green" }
}}
/>
</React.Fragment>
</div>
);
}