Last active
August 29, 2015 14:16
-
-
Save bloodyowl/64a4f5349fce6f28e5ea 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
import React, {Component} from "react" | |
import shallowEqual from "react/lib/shallowEqual" | |
/** | |
* example : | |
* | |
* import React, {Component, PropTypes} from "react" | |
* | |
* class MyComponent extends Component { | |
* | |
* static propTypes = { | |
* someProp : PropTypes.string, | |
* someOtherProp : PropTypes.string, | |
* } | |
* | |
* render() { | |
* return ( | |
* <div> | |
* <SubComponent someProp={this.props.someProp} /> | |
* <OtherSubComponent someOtherProp={this.props.someOtherProp} /> | |
* </div> | |
* ) | |
* } | |
* } | |
* | |
* export default PureRender(MyComponent) | |
* | |
*/ | |
export default (Component) => { | |
class PureRender extends Component { | |
shouldComponentUpdate(nextProps) { | |
return shallowEqual(this.props, nextProps) | |
} | |
render() { | |
return <Component {...this.props} /> | |
} | |
} | |
return PureRender | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment