Files
lemma/frontend/src/contexts/FileContentContext.js
2024-10-04 21:21:24 +02:00

25 lines
630 B
JavaScript

import React, { createContext, useContext } from 'react';
import { useFileContent } from '../hooks/useFileContent';
const FileContentContext = createContext();
export const FileContentProvider = ({ children }) => {
const fileContentHook = useFileContent();
return (
<FileContentContext.Provider value={fileContentHook}>
{children}
</FileContentContext.Provider>
);
};
export const useFileContentContext = () => {
const context = useContext(FileContentContext);
if (!context) {
throw new Error(
'useFileContentContext must be used within a FileContentProvider'
);
}
return context;
};