-
-
Save nicolascine/fafb5540df121373a2c80c1de4c0b8b7 to your computer and use it in GitHub Desktop.
This file contains 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
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; | |
export function withAppContext< | |
P extends { appContext?: AppContextInterface }, | |
R = Omit<P, 'appContext'> | |
>( | |
Component: React.ComponentClass<P> | React.StatelessComponent<P> | |
): React.SFC<R> { | |
return function BoundComponent(props: R) { | |
return ( | |
<AppContextConsumer> | |
{value => <Component {...props} appContext={value} />} | |
</AppContextConsumer> | |
); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment