Arrays become lists
Most real-world React is rendering lists — users, products, messages, notifications. You already know.map() from the array methods lesson. In React, .map() turns an array of data into an array of JSX elements.
.map() over an array, return JSX for each item, add a key prop. You’ll use this in virtually every React component.
The key prop
Every item in a list needs a uniquekey prop. React uses keys to track which items changed, were added, or were removed.
What makes a good key?
Rendering components from a list
Usually you render a component for each item, not raw HTML:The
key goes on the outermost element in the .map() — which is the <UserCard> component, not any element inside it. React needs the key on the mapped element, not on a child within it.Filtering and transforming before rendering
Process your data before the return statement. Don’t try to do complex logic inside JSX:A searchable list — putting it together
This combines state, effects, list rendering, and conditional rendering:Common mistakes
Forgetting the key prop
Forgetting the key prop
Putting key on the wrong element
Putting key on the wrong element
Forgetting parentheses in .map()
Forgetting parentheses in .map()
What’s next?
You can render lists of data. Now let’s learn how to handle user input — forms are how users interact with your app.Forms in React
Build controlled forms that sync input values with React state