import { useContext } from 'react' ; import { ResourceContext , ResourceContextValue } from './ResourceContext' ; example returns { ResourceContextValue } export const useResourceContext = < ResourceInformationsType extends Partial < { resource : string ; } > > ( props ? ) : ResourceContextValue => { const context = useContext ( ResourceContext ) ; return ( props && props . resource ) || context ; } ;