import { useContext , useMemo } from 'react' ; import defaults from 'lodash/defaults' ; import { Record } from '../../types' ; import { EditContext } from './EditContext' ; import { EditControllerProps } from './useEditController' ; typedef { Object } EditControllerProps returns { EditControllerProps } see useEditController export const useEditContext = < RecordType extends Record = Record > ( props ? ) : Partial < EditControllerProps < RecordType > > => { const context = useContext < EditControllerProps < RecordType > > ( EditContext ) ; return useMemo ( ( ) => defaults ( { } , props != null ? extractEditContextProps ( props ) : { } , context ) , [ context , props ] ) ; } ; param { Object } props returns { EditControllerProps } const extractEditContextProps = ( { basePath , data , record , defaultTitle , onFailureRef , onSuccessRef , transformRef , loaded , loading , redirect , setOnFailure , setOnSuccess , setTransform , resource , save , saving , successMessage , version , } ) => ( { basePath , data : record || data , record : record || data , defaultTitle , onFailureRef , onSuccessRef , transformRef , loaded , loading , redirect , setOnFailure , setOnSuccess , setTransform , resource , save , saving , successMessage , version , } ) ;