Created
April 16, 2015 01:16
-
-
Save koba04/0233ffa25fd77472fe4f to your computer and use it in GitHub Desktop.
React static component by higher order function.
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 from 'react'; | |
import StaticHeader from './StaticHeader'; | |
React.render(<StaticHeader name="foo" />, document.getElementById('app')); |
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 from 'react'; | |
const Static = Component => class extends React.Component { | |
shouldComponentUpdate() { | |
return false; | |
} | |
render() { | |
return <Component {...this.props} />; | |
} | |
}; | |
export default Static; |
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 from 'react'; | |
import Static from './StaticComponent'; | |
class Header extends React.Component { | |
render() { | |
return <div>Hello {this.props.name}</div>; | |
} | |
} | |
export default StaticComponent(Header); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment