UNPKG

ra-core

Version:

Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React

24 lines (21 loc) 686 B
import { useContext } from 'react'; import { ListSortContext, ListSortContextValue } from './ListSortContext'; /** * Hook to read the list sort controller props from the ListSortContext. * * Must be used within a <ListSortContextProvider> (e.g. as a descendent of <List> * or <ListBase>). * * @returns {ListSortContextValue} list controller props * * @see useListController for how it is filled */ export const useListSortContext = (): ListSortContextValue => { const context = useContext(ListSortContext); if (!context) { throw new Error( 'useListSortContext must be used inside a ListSortContextProvider' ); } return context; };