import { createContext , useMemo } from 'react' ; import pick from 'lodash/pick' ; import { ListControllerProps } from './useListController' ; typedef ListPaginationContextValue prop { boolean } loading prop { integer } total prop { integer } page prop { Function } setPage prop { integer } perPage prop { Function } setPerPage prop { string } resource typedef Props prop { ListPaginationContextValue } value param { Props } see useListController see useListContext example const ListPaginationContext = createContext < ListPaginationContextValue > ( { loading : null , page : null , perPage : null , setPage : null , setPerPage : null , total : null , resource : null , } ) ; ListPaginationContext . displayName = 'ListPaginationContext' ; export type ListPaginationContextValue = Pick < ListControllerProps , 'loading' | 'page' | 'perPage' | 'setPage' | 'setPerPage' | 'total' | 'resource' > ; export const usePickPaginationContext = ( context ) : ListPaginationContextValue => useMemo ( ( ) => pick ( context , [ 'loading' , 'page' , 'perPage' , 'setPage' , 'setPerPage' , 'total' , 'resource' , ] ) , [ context . loading , context . page , context . perPage , context . setPage , context . setPerPage , context . total , ] ) ; export default ListPaginationContext ;