mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-06 16:04:23 +00:00
25 lines
630 B
JavaScript
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;
|
|
};
|