Back to course

Lists and Keys

React JS 0 to Hero: The Complete Guide

Rendering Lists

Use .map() to loop through arrays and return components. Each item needs a unique key prop.

jsx

<ul> {users.map(user => ( <li key={user.id}>{user.name}</li> ))} </ul>

Keys help React identify which items changed.