ra-core
Version:
Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React
26 lines • 1.06 kB
JavaScript
import * as React from 'react';
import { useListContextWithProps } from "./useListContextWithProps.js";
import { RecordContextProvider } from "../record/index.js";
export var RecordsIterator = function (props) {
var children = props.children, render = props.render;
var _a = useListContextWithProps(props), data = _a.data, total = _a.total, isPending = _a.isPending, error = _a.error;
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(function (record, index) {
var _a;
return (React.createElement(RecordContextProvider, { key: (_a = record.id) !== null && _a !== void 0 ? _a : "row".concat(index), value: record }, render ? render(record, index) : children));
})));
};
/**
* @deprecated use RecordsIterator instead.
*/
export var ListIterator = RecordsIterator;
//# sourceMappingURL=RecordsIterator.js.map