Let's assume that we created a simple React component to display some fruits. If we wanted to render a multiline map function, we could use a parenthesis after the arrow.
Example:
jsximport React from 'react'; const App = () => { const fruits = [ {name: 'banana', emoji: '🍌'}, {name: 'apple', emoji: '🍎'}, {name: 'grape', emoji: '🍇'} ]; return( <div className = 'Fruits'> {fruits.map(({name, emoji}) => ( <div className = 'Fruit'> I'm a {name} and my icon is {emoji} </div> ))} </div> ); } export default App;
Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.