Rendering data and responding

Lists with keys, conditional rendering, and event handlers for clicks, keys and forms.

About 4 hours of study

Learning objectives

Lessons

  1. 1

    Lists and keys Intermediate

    Rendering arrays with map, filtering and sorting before rendering, why every item needs a key, and how to choose a good one.

  2. 2

    Conditional rendering Intermediate

    Showing different things in different situations: returning early, the conditional operator, the && operator and its 0 trap, returning null, and choosing between components.

  3. 3

    Responding to events Intermediate

    Handling clicks, key presses and form submissions: passing functions to onClick and friends, the event object, passing arguments with arrow functions, preventDefault, and passing handlers down as props.

Module practice

Module quiz

1. What should a list item's key be?
2. Which is correct?
3. What does {count && <Badge />} show when count is 0?
4. How do you pass 'Tea' to pick when a button is clicked?
5. Why call event.preventDefault() in onSubmit?
6. Why can index keys break a list whose items are deleted?

‹ React foundationsState and forms ›