import { ReactNode } from 'react';
import { RaRecord } from '../../types';
import {
useListController,
ListControllerProps,
ListControllerResult,
} from './useListController';
/**
* Render prop version of the useListController hook.
*
* @see useListController
* @example
*
* const ListView = () =>
...
;
* const List = props => (
*
* {controllerProps => }
*
* )
*/
export const ListController = <
RecordType extends RaRecord = any,
ErrorType = Error,
>({
children,
...props
}: {
children: (
params: ListControllerResult
) => ReactNode;
} & ListControllerProps) => {
const controllerProps = useListController(props);
return children(controllerProps);
};