16 lines
465 B
TypeScript
16 lines
465 B
TypeScript
import { createContext, useContext } from 'react';
|
|
import type { Project } from '@life-platform/shared';
|
|
|
|
export interface ProjectContext {
|
|
project: Project;
|
|
}
|
|
|
|
export const ProjectContextValue = createContext<ProjectContext | null>(null);
|
|
|
|
export function useProjectContext(): ProjectContext {
|
|
const ctx = useContext(ProjectContextValue);
|
|
if (!ctx) {
|
|
throw new Error('useProjectContext must be used within a ProjectContextProvider');
|
|
}
|
|
return ctx;
|
|
}
|