Last active
November 26, 2024 17:33
-
-
Save ruanvalente/b37dee41462f23f3aca5e357b0daa24b to your computer and use it in GitHub Desktop.
ForComponent
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 React, { ReactNode } from 'react'; | |
| interface ForProps<T> { | |
| each: T[]; | |
| render: (item: T, index: number) => ReactNode; | |
| } | |
| export function For<T>({ each, render }: ForProps<T>) { | |
| return <>{each.map((item, index) => render(item, index))}</>; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment