Skip to content

Instantly share code, notes, and snippets.

@mattmccray
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save mattmccray/33e47db69b40a5c6dd93 to your computer and use it in GitHub Desktop.

Select an option

Save mattmccray/33e47db69b40a5c6dd93 to your computer and use it in GitHub Desktop.
React Pure Render Function
export function SimpleComponent( renderFn ) {
return React.createClass({
displayName: renderFn.displayName || renderFn.name,
mixins:[ React.addons.PureRenderMixin ],
render() {
return renderFn.call( this, this.props )
}
})
}
export default SimpleComponent(function
/*
Button Component
*/
Button({ label, icon, size='default', ...attrs }) {
return (
<button className={`Button size-${ size }` {...attrs}>
{ icon && <i className={`fa fa-${ icon }`}/> }
{ label }
</button>
)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment