import { createContext , useMemo } from 'react' ; import pick from 'lodash/pick' ; import { ListControllerProps } from './useListController' ; typedef ListFilterContextValue prop { Object } filterValues prop { Function } setFilters prop { Object } displayedFilters prop { Function } showFilter prop { Function } hideFilter prop { string } resource typedef Props prop { ListFilterContextValue } value param { Props } see useListController see useListFilterContext example const ListFilterContext = createContext < ListFilterContextValue > ( { displayedFilters : null , filterValues : null , hideFilter : null , setFilters : null , showFilter : null , resource : null , } ) ; export type ListFilterContextValue = Pick < ListControllerProps , 'displayedFilters' | 'filterValues' | 'hideFilter' | 'setFilters' | 'showFilter' | 'resource' > ; export const usePickFilterContext = ( context ) : ListFilterContextValue => useMemo ( ( ) => pick ( context , [ 'displayedFilters' , 'filterValues' , 'hideFilter' , 'setFilters' , 'showFilter' , 'resource' , ] ) , [ context . displayedFilters , context . filterValues , context . hideFilter , context . setFilters , context . showFilter , ] ) ; ListFilterContext . displayName = 'ListFilterContext' ; export default ListFilterContext ;