Repaso
EspaƱol
Frontend & WebIntermediateFE-44

When do you use React Context?

Options

  1. To share a value like a theme without prop drilling (Correct option)
  2. To store the data of the application on the server
  3. To style the components of the application with CSS
  4. To run the tests of the components of the app

Answer

To share values like the current user or theme with many components without passing props through every level (prop drilling)

Why

Prop drilling means passing a prop through many intermediate components that do not use it, just to reach a deep child.

Context lets a provider component make a value available to any descendant that calls useContext.

Good for rarely changing, app-wide data (theme, locale, logged-in user). For complex or frequently changing global state, libraries such as Redux Toolkit, Zustand, or server-state tools like TanStack Query are often used.

Remember

Context = shared value without prop drilling.

Key terms

Practice this question in Repaso