import { useContext , useMemo } from 'react' ; import defaults from 'lodash/defaults' ; import { Record } from '../../types' ; import { ShowContext } from './ShowContext' ; import { ShowControllerProps } from './useShowController' ; typedef { Object } ShowControllerProps returns { ShowControllerProps } see useShowController export const useShowContext = < RecordType extends Record = Record > ( props ? ) : Partial < ShowControllerProps < RecordType > > => { const context = useContext < ShowControllerProps < RecordType > > ( ShowContext ) ; return useMemo ( ( ) => defaults ( { } , props != null ? extractShowContextProps ( props ) : { } , context ) , [ context , props ] ) ; } ; param { Object } props returns { ShowControllerProps } const extractShowContextProps = ( { basePath , record , data , defaultTitle , loaded , loading , resource , version , } ) => ( { basePath , record : record || data , data : record || data , defaultTitle , loaded , loading , resource , version , } ) ;