Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const ImageUploadButton = props => {
const [uploadTask, setUploadTask] = useState(null);
const [ref, setRef] = useState(null);
const storage = useStorage();
const onChange = event => {
const fileList = event.target.files;
const fileToUpload = fileList[0];
const fileName = fileToUpload.name;
const newRef = storage()
.ref('images')
.child(fileName);
setRef(newRef);
const uploadTask = newRef.put(fileToUpload);
uploadTask.then(() => {
console.log('upload complete');
setUploadTask(null);
});
setUploadTask(uploadTask);