UNPKG

ra-core

Version:

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

37 lines 1.44 kB
import { ListControllerResult } from "./useListController.cjs"; /** * Context to store the sort part of the useListController() result. * * Use the useListSortContext() hook to read the context. That's what many * List components do in react-admin (e.g. <SortButton>). * * @typedef {Object} ListSortContextValue * @prop {Object} sort a sort object { field, order }, e.g. { field: 'date', order: 'DESC' } * @prop {Function} setSort a callback to change the sort, e.g. setSort({ field: 'name', order: 'ASC' }) * @prop {string} resource the resource name, deduced from the location. e.g. 'posts' * * @typedef Props * @prop {ListSortContextValue} value * * @param {Props} * * @see useListController * @see useListSortContext * * @example * * import { useListController, usePickSortContext, ListSortContext } from 'ra-core'; * * const List = props => { * const controllerProps = useListController(props); * return ( * <ListSortContext.Provider value={usePickSortContext(controllerProps)}> * ... * </ListSortContext.Provider> * ); * }; */ export declare const ListSortContext: import("react").Context<ListSortContextValue | undefined>; export type ListSortContextValue = Pick<ListControllerResult, 'sort' | 'setSort' | 'resource'>; export declare const usePickSortContext: (context: ListControllerResult) => ListSortContextValue; //# sourceMappingURL=ListSortContext.d.ts.map