foreach in react

Solutions on MaxInterview for foreach in react by the best coders in the world

showing results for - "foreach in react"
Anna
03 Jun 2017
1render() {
2	const myArray = [];
3    return <>
4		{myArray.map(item => {
5			return (<Element>
6    			{item}
7		    </Element>);
8		});}
9    </>
10}
Theo
15 Jan 2020
1You need to pass an array of element to jsx. 
2The problem is that forEach does not return anything (i.e it returns undefined).
3So it's better to use map because map returns an array:
4
5***