mirror of
https://github.com/khairul169/code-share.git
synced 2025-06-17 17:19:34 +07:00
19 lines
381 B
TypeScript
19 lines
381 B
TypeScript
|
import { createContext, useContext } from "react";
|
||
|
|
||
|
type TProjectContext = {
|
||
|
isCompact?: boolean;
|
||
|
};
|
||
|
|
||
|
const ProjectContext = createContext<TProjectContext | null>(null);
|
||
|
|
||
|
export const useProjectContext = () => {
|
||
|
const ctx = useContext(ProjectContext);
|
||
|
if (!ctx) {
|
||
|
throw new Error("Component not in ProjectContext!");
|
||
|
}
|
||
|
|
||
|
return ctx;
|
||
|
};
|
||
|
|
||
|
export default ProjectContext;
|