Rendering data and responding
Lists with keys, conditional rendering, and event handlers for clicks, keys and forms.
About 4 hours of study
Learning objectives
- Render lists with stable keys
- Show content conditionally
- Handle events and pass handlers as props
Lessons
- 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
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
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
- React: A shopping list from an arrayEasy
- React: Contacts grouped by letterMedium
- React: A ranked results tableHard
- React: Signed in or notEasy
- React: A cart badge without a stray zeroMedium
- React: Every state of a requestHard
- React: Buttons that report a colourEasy
- React: React to keys in an inputMedium
- React: A search form with submit and resetHard