Created
May 5, 2020 00:56
-
-
Save simpleshadow/07792f824893787f2555c5d531616d4c to your computer and use it in GitHub Desktop.
π
This file contains 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
type StopItProps<T> = { | |
items: T[] | |
callback: (item: T, index: number) => JSX.Element | |
} | |
const stopIt = <T,>(items: StopItProps<T>['items']) => ( | |
callback: StopItProps<T>['callback'] | |
): JSX.Element[] => | |
items.map((item, i) => ( | |
<React.Fragment key={`corey-was-here-${i}-${Date.now()}`}>{callback(item, i)}</React.Fragment> | |
)) | |
export default <T,>({ items, callback }: StopItProps<T>) => <>{stopIt(items)(callback)}</> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment