Skip to content

Instantly share code, notes, and snippets.

@koba04
Created April 16, 2015 01:16
Show Gist options
  • Save koba04/0233ffa25fd77472fe4f to your computer and use it in GitHub Desktop.
Save koba04/0233ffa25fd77472fe4f to your computer and use it in GitHub Desktop.
React static component by higher order function.
import React from 'react';
import StaticHeader from './StaticHeader';
React.render(<StaticHeader name="foo" />, document.getElementById('app'));
import React from 'react';
const Static = Component => class extends React.Component {
shouldComponentUpdate() {
return false;
}
render() {
return <Component {...this.props} />;
}
};
export default Static;
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