mirror of
https://github.com/khairul169/code-share.git
synced 2025-04-28 16:49:36 +07:00
20 lines
397 B
TypeScript
20 lines
397 B
TypeScript
import { createContext, useContext } from "react";
|
|
|
|
type TProjectContext = {
|
|
slug: string;
|
|
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;
|