Created
January 12, 2018 05:45
-
-
Save mariorodriguespt/6a1efa2ab8ae2ceaee79d6ec773e5fd7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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