Answers for "jsx foreach"

1

jsx foreach

render() {
	const myArray = [];
    return <>
		{myArray.map(item => {
			return (<Element>
    			{item}
		    </Element>);
		});}
    </>
}
Posted by: Guest on January-20-2021
1

foreach in react

You need to pass an array of element to jsx. 
The problem is that forEach does not return anything (i.e it returns undefined).
So it's better to use map because map returns an array:

***
Posted by: Guest on July-30-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language