Created
January 7, 2017 16:09
-
-
Save thomasboyt/b9fb54f9a0309ca8027bb7da481a10e7 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 * as React from 'react'; | |
import {ColorScheme} from '../../universal/resources'; | |
interface Context { | |
colorScheme: ColorScheme; | |
} | |
/** | |
* Injects this.context.colorScheme as a prop | |
*/ | |
export default function withColorScheme<C extends React.ComponentClass<any>>(Component: C): C { | |
return class ColorSchemeWrapper extends React.Component<any, {}> { | |
context: Context; | |
static contextTypes = { | |
colorScheme: React.PropTypes.object.isRequired, | |
}; | |
render() { | |
const {colorScheme} = this.context; | |
return <Component {...this.props} colorScheme={colorScheme} />; | |
} | |
} | |
} | |
// line 13: [ts] Type 'typeof ColorSchemeWrapper' is not assignable to type 'C'. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment