Building bigger apps
Reducers for complex updates, context for app-wide values, and the process of designing a React interface.
About 4 hours of study
Learning objectives
- Manage state with reducers
- Share values with context
- Design component hierarchies and state
Lessons
- 1
Reducers: organising state changes Advanced
useReducer for state with many kinds of updates: actions that describe what happened, a pure reducer function that computes the next state, dispatching from event handlers, and when to prefer a reducer to useState.
- 2
Context: sharing values across the tree Advanced
Passing data deep into the tree without prop drilling: createContext, providing a value, useContext, combining context with state and reducers, and when context is and is not the right tool.
- 3
Thinking in React Advanced
How to build a React interface from a design: break it into a component hierarchy, build a static version from props, find the minimal state, decide where it lives, and add inverse data flow.
Module practice
- React: A counter with a reducerEasy
- React: A to-do list with a reducerMedium
- React: A shopping cart reducerHard
- React: Cards that read the themeEasy
- React: The signed-in user in contextMedium
- React: Translations from contextHard
- React: A filterable listEasy
- React: A table sorted by its headersMedium
- React: A small task boardHard