import React from 'react'; import { ListContextProvider, useList, useListContext } from '.'; import type { UseListValue } from '.'; export default { title: 'ra-core/controller/list/useList', }; const ListView = () => { const listContext = useListContext(); return (
{listContext.isPending ? (

Loading...

) : (

Selected ids:{' '} {JSON.stringify(listContext.selectedIds)}

)}
); }; const data = [ { id: 1, title: 'War and Peace' }, { id: 2, title: 'The Little Prince' }, { id: 3, title: "Swann's Way" }, { id: 4, title: 'A Tale of Two Cities' }, { id: 5, title: 'The Lord of the Rings' }, { id: 6, title: 'And Then There Were None' }, { id: 7, title: 'Dream of the Red Chamber' }, { id: 8, title: 'The Hobbit' }, { id: 9, title: 'She: A History of Adventure' }, { id: 10, title: 'The Lion, the Witch and the Wardrobe' }, ]; const Wrapper = ({ children = , callback, ...props }: { children: React.ReactNode; callback?: (value: UseListValue) => void; }) => { const value = useList({ data, sort: { field: 'id', order: 'ASC' }, ...props, }); callback && callback(value); return {children}; }; export const Basic = props => ; const SortButton = () => { const listContext = useListContext(); return (
); }; export const Sort = props => ( ); const SelectAllButton = () => { const value = useListContext(); return (
); }; export const SelectAll = props => ( );