1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2025-01-09 23:39:46 +00:00
sophon/frontend/src/contexts/project.tsx

22 lines
750 B
TypeScript
Raw Normal View History

2021-10-14 03:05:01 +00:00
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}/>
}