admin-on-rest-fr05t1k
Version:
A frontend Framework for building admin applications on top of REST services, using ES6, React and Material UI
26 lines (20 loc) • 568 B
JavaScript
import React, { PropTypes } from 'react';
import get from 'lodash.get';
import pure from 'recompose/pure';
const UrlField = ({ source, record = {}, elStyle }) => (
<a href={get(record, source)} style={elStyle}>
{get(record, source)}
</a>
);
UrlField.propTypes = {
addLabel: PropTypes.bool,
elStyle: PropTypes.object,
label: PropTypes.string,
record: PropTypes.object,
source: PropTypes.string.isRequired,
};
const PureUrlField = pure(UrlField);
PureUrlField.defaultProps = {
addLabel: true,
};
export default PureUrlField;