1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2025-01-09 15:29:47 +00:00
sophon/frontend/src/contexts/project.tsx
2021-10-17 01:32:28 +02:00

21 lines
750 B
TypeScript

import * as React from "react"
import {ManagedResource} from "../hooks/useManagedViewSet"
import {WithChildren, WithResource} from "../types/ExtraTypes"
import {SophonResearchProject} from "../types/SophonTypes"
const projectContext = React.createContext<ManagedResource<SophonResearchProject> | undefined>(undefined)
const ProjectContext = projectContext
/**
* Hook to access the {@link projectContext}.
*/
export function useProjectContext(): ManagedResource<SophonResearchProject> | undefined {
return React.useContext(projectContext)
}
export function ProjectProvider({resource, children}: WithResource<SophonResearchProject> & WithChildren): JSX.Element {
return <ProjectContext.Provider value={resource} children={children}/>
}