Skip to content

Instantly share code, notes, and snippets.

View jpkempf's full-sized avatar

Jan-Philipp Kempf jpkempf

View GitHub Profile
@jpkempf
jpkempf / HOC.ts
Created January 30, 2024 15:52 — forked from vezaynk/HOC.ts
HOC helpers. reduceHOCs and applyHOCs.
interface HOC<T> {
(Component: React.ComponentType<T>): (props: T) => JSX.Element
}
const reduceHOCs = <T>(...hocs: HOC<T>[]): HOC<T> => hocs
.reduce((reduced, next) => (c) => next(reduced(c)));
const applyHOCs = <T>(...hocs: HOC<T>[]) {
const reducedHoc = reduceHOCs(...hocs);