Last active
July 22, 2016 22:14
-
-
Save jamsesso/648939220f401cb732b330f81379b03d 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
import React, { Component } from 'react' | |
function withContext(key, type) { | |
return WrappedComponent => class ContextComponent extends Component { | |
static contextTypes = { | |
...WrappedComponent.contextTypes, | |
[key]: type | |
} | |
render() { | |
return ( | |
<WrappedComponent {...this.context} {...this.props} /> | |
) | |
} | |
} | |
} | |
export default withContext |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment