import { createContext , useMemo } from 'react' ; import pick from 'lodash/pick' ; import { ListControllerProps } from './useListController' ; typedef ListSortContextValue prop { Object } currentSort prop { Function } setSort prop { string } resource typedef Props prop { ListSortContextValue } value param { Props } see useListController see useListSortContext example const ListSortContext = createContext < ListSortContextValue > ( { currentSort : null , setSort : null , resource : null , } ) ; export type ListSortContextValue = Pick < ListControllerProps , 'currentSort' | 'setSort' | 'resource' > ; export const usePickSortContext = ( context ) : ListSortContextValue => useMemo ( ( ) => pick ( context , [ 'currentSort' , 'setSort' , 'resource' ] ) , [ context . currentSort , context . setSort ] ) ; ListSortContext . displayName = 'ListSortContext' ; export default ListSortContext ;