Skip to content

Instantly share code, notes, and snippets.

@michal-wrzosek
Created February 26, 2019 08:01
Show Gist options
  • Save michal-wrzosek/48682b20df2811e9e4354e6c5ac71471 to your computer and use it in GitHub Desktop.
Save michal-wrzosek/48682b20df2811e9e4354e6c5ac71471 to your computer and use it in GitHub Desktop.
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