import React from 'react'; import PropTypes from 'prop-types'; //import style from './style.css'; const renderIcon = icon => { if (!icon) { return; } if (typeof icon === 'string') { return ; } else { const Icon = icon; return ; } }; const Message = ({ icon, heading, children }) => (

{ renderIcon(icon) }{ heading }

{ children }
); Message.propTypes = { icon: PropTypes.oneOfType([ PropTypes.element, PropTypes.func, PropTypes.string ]), heading: PropTypes.string.isRequired, children: PropTypes.element.isRequired }; export default Message;