Skip to content

Instantly share code, notes, and snippets.

View nielsboecker's full-sized avatar

Niels Boecker nielsboecker

View GitHub Profile
@stephenwil
stephenwil / Context.tsx
Created May 29, 2018 09:59
Typescript HOC Context
export const withContext = <P extends {}>(Component: React.ComponentType<P>) =>
class WithContext extends React.PureComponent<P & IAppContext> {
render() {
return (
<AppContext.Consumer>
{(context: any) => <Component {...this.props} {...context} />}
</AppContext.Consumer>
);
}
};