Last active
June 22, 2018 09:06
-
-
Save diegohaz/59e78e397c16ce2e6d854963f866f8aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const callAll = (...fns) => (...args) => fns.forEach(fn => fn && fn(...args)); | |
const internalOnLoad = () => console.log("loaded"); | |
const Avatar = ({ className, style, onLoad, ...props }) => ( | |
<img | |
className={`avatar ${className}`} | |
style={{ borderRadius: "50%", ...style }} | |
onLoad={callAll(internalOnLoad, onLoad)} | |
{...props} | |
/> | |
); | |
Avatar.propTypes = { | |
src: PropTypes.string.isRequired, | |
alt: PropTypes.string.isRequired, | |
className: PropTypes.string, | |
style: PropTypes.object, | |
onLoad: PropTypes.func | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment