import { useContext , useMemo } from 'react' ; import defaults from 'lodash/defaults' ; import { ReferenceArrayInputContext , ReferenceArrayInputContextValue , } from './ReferenceArrayInputContext' ; /**
 * Hook to get the ReferenceArrayInputContext.
 */ export const useReferenceArrayInputContext = < T extends ReferenceArrayInputContextValue = ReferenceArrayInputContextValue > ( props ) : ReferenceArrayInputContextValue => { const context = useContext ( ReferenceArrayInputContext ) ; return useMemo ( ( ) => defaults ( { } , props != null ? extractReferenceArrayInputContextProps ( props ) : { } , context ) , [ context , props ] ) ; } ; const extractReferenceArrayInputContextProps = < T extends ReferenceArrayInputContextValue = ReferenceArrayInputContextValue > ( { choices , error , loaded , loading , setFilter , setPagination , setSort , setSortForList , warning , } ) => ( { choices , error , loaded , loading , setFilter , setPagination , setSort , setSortForList , warning , } ) ;