Created
September 10, 2018 20:46
-
-
Save vilindberg/8c7fe353e5803636962b5ff83d8c9f8b to your computer and use it in GitHub Desktop.
Compose React hocs
This file contains hidden or 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
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