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.66 kB
JavaScript
import * as React from 'react';
import { ListContext } from "./ListContext.js";
import { ListFilterContext, usePickFilterContext } from "./ListFilterContext.js";
import { ListSortContext, usePickSortContext } from "./ListSortContext.js";
import { ListPaginationContext, usePickPaginationContext, } from "./ListPaginationContext.js";
/**
* Create a List Context and several thematic List subcontext.
*
* Allows children to subscribe to part of the ListContext, and bail out of
* rendering when some parts of the context that they don't depend on change
* (because unfortunately React doesn't allow to use context selectors yet).
*
* @example
*
* const MyList = (props) => {
* const controllerProps = useListController(props);
* return (
* <ListContextProvider value={controllerProps}>
* <MyListView>
* </ListContextProvider>
* );
* };
*
* const MyListView = () => {
* const { data, filterValues, setFilters } = useListContext();
* // or, to rerender only when filters change but not data
* const { filterValues, setFilters } = useListFilterContext();
* }
*
* @see ListContext
* @see ListFilterContext
*/
export const ListContextProvider = ({ value, children, }) => (React.createElement(ListContext.Provider, { value: value },
React.createElement(ListFilterContext.Provider, { value: usePickFilterContext(value) },
React.createElement(ListSortContext.Provider, { value: usePickSortContext(value) },
React.createElement(ListPaginationContext.Provider, { value: usePickPaginationContext(value) }, children)))));
//# sourceMappingURL=ListContextProvider.js.map