Skip to content

Instantly share code, notes, and snippets.

View nielsboecker's full-sized avatar

Niels Boecker nielsboecker

View GitHub Profile
@nielsboecker
nielsboecker / SomeComponent.tsx
Last active July 27, 2019 15:17
TypeScript HOC (Higher-Order Component) for wrapping React components with context consumers
// Usage in other components
import { PropsWithContext, withAppContext } from "./WithAppContext";
export interface ISomeComponentProps extends PropsWithContext {
otherProp: string;
}
class SomeComponent extends Component<ISomeComponentProps> {
// or: can also extend Component<PropsWithContext> or extend Component<SomeProps & PropsWithContext>