admin-on-rest-fr05t1k
Version:
A frontend Framework for building admin applications on top of REST services, using ES6, React and Material UI
31 lines (27 loc) • 831 B
JavaScript
import React, { PropTypes } from 'react';
/**
* Iterator component to be used to display a list of entities, using a single field
*
* @example Display all the books by the current author
* <ReferenceManyField reference="books" target="author_id">
* <SingleFieldList>
* <ChipField source="title" />
* </SingleFieldList>
* </ReferenceManyField>
*/
const SingleFieldList = ({ ids, data, resource, basePath, children }) => (
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
{ids.map(id =>
React.cloneElement(children, {
key: id,
record: data[id],
resource,
basePath,
})
)}
</div>
);
SingleFieldList.propTypes = {
children: PropTypes.element.isRequired,
};
export default SingleFieldList;