1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-23 07:14:21 +00:00
sophon/frontend/src/contexts/group.tsx

22 lines
726 B
TypeScript
Raw Normal View History

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