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