UNPKG

admin-on-rest-fr05t1k

Version:

A frontend Framework for building admin applications on top of REST services, using ES6, React and Material UI

28 lines (22 loc) 715 B
import React, { PropTypes } from 'react'; import pure from 'recompose/pure'; /** * @example * <FunctionField source="last_name" label="Name" render={record => `${record.first_name} ${record.last_name}`} /> */ const FunctionField = ({ record = {}, source, render, elStyle }) => record ? <span style={elStyle}>{render(record)}</span> : null; FunctionField.propTypes = { addLabel: PropTypes.bool, elStyle: PropTypes.object, label: PropTypes.string, render: PropTypes.func.isRequired, record: PropTypes.object, source: PropTypes.string, }; const PureFunctionField = pure(FunctionField); PureFunctionField.defaultProps = { addLabel: true, }; export default PureFunctionField;