Skip to content

Instantly share code, notes, and snippets.

@ruanvalente
Last active November 26, 2024 17:33
Show Gist options
  • Save ruanvalente/b37dee41462f23f3aca5e357b0daa24b to your computer and use it in GitHub Desktop.
Save ruanvalente/b37dee41462f23f3aca5e357b0daa24b to your computer and use it in GitHub Desktop.
ForComponent
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