foreach in react

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

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
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***