Created
February 26, 2019 08:01
-
-
Save michal-wrzosek/48682b20df2811e9e4354e6c5ac71471 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> = Pick<T, Exclude<keyof T, K>>; | |
type Theme = { | |
fontColor: string; | |
}; | |
type WithThemeProps = { | |
theme: Theme; | |
}; | |
const withTheme = <P extends object>(Component: React.ComponentType<P>) => | |
class WithTheme extends React.Component<Omit<P, keyof WithThemeProps>> { | |
render() { | |
return <Component {...this.props as P} theme={theme} />; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment