Want to concatenate JSX elements into an array? Below is an example to concatenate JSX elements into an array.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | processItems(itemArray) { // Create an empty array that will hold the final JSX output. let buffer = [] buffer.push(<div>A</div>); buffer.push(<div>B</div>); buffer.push(<div>C</div>); // And return the buffer for display inside the render() function return ( <div className"container flex center"> {buffer} </div> ); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.