Last active
August 29, 2015 14:27
-
-
Save mattmccray/33e47db69b40a5c6dd93 to your computer and use it in GitHub Desktop.
React Pure Render Function
This file contains hidden or 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
| 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