Skip to content

Instantly share code, notes, and snippets.

@vilindberg
Created September 10, 2018 20:46
Show Gist options
  • Save vilindberg/8c7fe353e5803636962b5ff83d8c9f8b to your computer and use it in GitHub Desktop.
Save vilindberg/8c7fe353e5803636962b5ff83d8c9f8b to your computer and use it in GitHub Desktop.
Compose React hocs
import { ComponentClass } from 'react'
export const compose = <P>(
...hocs: any[]
): ((comp: ((props: P) => JSX.Element) | ComponentClass<P>) => ComponentClass<P>) =>
hocs.reduceRight((a, b) => (arg: any) => b(a(arg)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment