UNPKG

ra-core

Version:

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

23 lines 904 B
import * as React from 'react'; import { useListContextWithProps } from "./useListContextWithProps.js"; import { RecordContextProvider } from "../record/index.js"; export const RecordsIterator = (props) => { const { children, render } = props; const { data, total, isPending, error } = useListContextWithProps(props); if (isPending === true || error || data == null || data.length === 0 || total === 0) { return null; } if (!render && !children) { return null; } return (React.createElement(React.Fragment, null, data.map((record, index) => (React.createElement(RecordContextProvider, { key: record.id ?? `row${index}`, value: record }, render ? render(record, index) : children))))); }; /** * @deprecated use RecordsIterator instead. */ export const ListIterator = RecordsIterator; //# sourceMappingURL=RecordsIterator.js.map