Last active
April 1, 2019 13:28
-
-
Save jrwebdev/bed055c2e024045cc6fe93ac27e2c4f5 to your computer and use it in GitHub Desktop.
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 { Subtract, Omit } from 'utility-types'; | |
| import MakeCounter, { MakeCounterProps, InjectedCounterProps } from './MakeCounter'; | |
| type MakeCounterHocProps = Omit<MakeCounterProps, 'children'>; | |
| const makeCounter = <P extends InjectedCounterProps>( | |
| Component: React.ComponentType<P> | |
| ): React.SFC<Subtract<P, InjectedCounterProps> & MakeCounterHocProps> => ({ | |
| minValue, | |
| maxValue, | |
| ...props | |
| }: MakeCounterHocProps) => ( | |
| <MakeCounter minValue={minValue} maxValue={maxValue}> | |
| {injectedProps => <Component {...props as P} {...injectedProps} />} | |
| </MakeCounter> | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment