Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JSX .map() method

// JSX .map() method
// The array method map() comes up often in React. It’s good to get in the habit of using it alongside JSX.

// If you want to create a list of JSX elements from a given array, then map() over each element in the array, returning a list item for each one.
const strings = ['Home', 'Shop', 'About Me'];

const listItems = strings.map(string => <li>{string}</li>);

<ul>{listItems}</ul>
Source by reactjs.org #
 
PREVIOUS NEXT
Tagged: #JSX #method
ADD COMMENT
Topic
Name
4+7 =