Add Contexts
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user