mirror of
https://github.com/khairul169/code-share.git
synced 2025-04-29 00:59:37 +07:00
21 lines
472 B
TypeScript
21 lines
472 B
TypeScript
import { createContext, useContext } from "react";
|
|
import type { ProjectSchema } from "~/server/db/schema/project";
|
|
|
|
type TProjectContext = {
|
|
project: ProjectSchema;
|
|
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;
|