Skip to main content

ForEach

A function that allows you to map over an array to dynamically render a collection of views

function ForEach<T>(
iterable: T[],
renderFn: (element: T, index: number) => ReactElement<any>
): ReactElement<any, string | React.JSXElementConstructor<any>>[];

Example​

const options = ['Option 1', 'Option 2', 'Option 3'];
<VStack>
{ForEach(options, (option, i) => (
<Text key={i}>{option}</Text>
))}
</VStack>