mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-08 08:54:21 +00:00
25 lines
703 B
JavaScript
25 lines
703 B
JavaScript
import React, { createContext, useContext } from 'react';
|
|
import { useFileManagementContext } from './FileManagementContext';
|
|
|
|
const FileSelectionContext = createContext();
|
|
|
|
export const FileSelectionProvider = ({ children }) => {
|
|
const { selectedFile, handleFileSelect } = useFileManagementContext();
|
|
|
|
return (
|
|
<FileSelectionContext.Provider value={{ selectedFile, handleFileSelect }}>
|
|
{children}
|
|
</FileSelectionContext.Provider>
|
|
);
|
|
};
|
|
|
|
export const useFileSelection = () => {
|
|
const context = useContext(FileSelectionContext);
|
|
if (context === undefined) {
|
|
throw new Error(
|
|
'useFileSelection must be used within a FileSelectionProvider'
|
|
);
|
|
}
|
|
return context;
|
|
};
|