Skip to content

Instantly share code, notes, and snippets.

@mariorodriguespt
Created January 12, 2018 05:45
Show Gist options
  • Save mariorodriguespt/6a1efa2ab8ae2ceaee79d6ec773e5fd7 to your computer and use it in GitHub Desktop.
Save mariorodriguespt/6a1efa2ab8ae2ceaee79d6ec773e5fd7 to your computer and use it in GitHub Desktop.
export default function connect(options) {
let expandedOptions = options;
if ( typeof options === 'function' ) {
expandedOptions = {
getMeteorData: options ,
};
}
const { getMeteorData , pure = true , contextTypes = {} } = expandedOptions;
const BaseComponent = pure ? ReactPureComponent : ReactComponent;
return ( WrappedComponent ) => {
return class ReactMeteorDataComponent extends BaseComponent {
static contextTypes = contextTypes;
getMeteorData() {
return getMeteorData( this.props , this.context );
}
render() {
return <WrappedComponent {...this.props} {...this.data} />;
}
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment