Add Contexts

This commit is contained in:
jwu-fisker
2021-01-05 17:30:55 -08:00
parent b0b49fe5e6
commit 378d00b220
2 changed files with 103 additions and 38 deletions

View File

@@ -3,23 +3,23 @@ import React, { useContext, useEffect, useState } from 'react';
const FileUploadContext = React.createContext();
export const FileUploadProvider = ({ children }) => {
const [file, setFile] = useState(null);
const [uploading, setUploading] = useState(false);
const [progress, setProgress] = useState(0);
const upload = (file) => {
const [file, setFile] = useState(null);
const [uploading, setUploading] = useState(false);
const [progress, setProgress] = useState(0);
};
const upload = (file) => {
return (
<FileUploadContext.Provider value={{
uploading,
progress,
upload,
}}>
{children}
</FileUploadContext.Provider>
);
};
return (
<FileUploadContext.Provider value={{
uploading,
progress,
upload,
}}>
{children}
</FileUploadContext.Provider>
);
};
export const useFileUploadContext = () => useContext(FileUploadContext);