Skip to content

Instantly share code, notes, and snippets.

@aliakakis
Created February 2, 2017 12:39
Show Gist options
  • Save aliakakis/794f4880835e13b75717dba9eab3de44 to your computer and use it in GitHub Desktop.
Save aliakakis/794f4880835e13b75717dba9eab3de44 to your computer and use it in GitHub Desktop.
import React, {Component, PropTypes} from 'react';
export const EnhanceDecorator = (options) => (TargetComponent) => {
class EnhanceComponent extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
render = () => {
return (
<ComposedComponent {...this.props} {...this.state} />
);
};
}
EnhanceComponent.defaultProps = {
};
EnhanceComponent.propTypes = {
};
return EnhanceComponent;
};
@aliakakis
Copy link
Author

@ EnhanceDecorator() // Do not forget the parentheses!!!
export default class MyComponent extends React.Component {...}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment