📊 We use cookies & analytics to improve your experience. Learn more
Latest

React & Modern Front-End Development Module 4 · Lesson 11 of 15

0% Exit to course

Module 4 · State that scales Lesson 11 of 15

Context: sharing state without prop drilling

Learning objective

Context lets a value be read by components far below without passing it down through every level. It is for the few things that are genuinely global: the signed-in user, the theme, the language.

Worked example

Wrap the app in a provider, then any component calls useContext(ThemeContext) and reads the current theme, however deep it sits.

Your practice task

Lift the current user into a Context and read it in a component three levels down without passing a prop.

Do this before moving on. Reading a solution teaches the shape of it; typing it teaches you.

Key takeaway

Context lets a value be read by components far below without passing it down through every level. It is for the few things that are genuinely global: the signed-in user, the theme, the language.

Create free account or sign in

Almost there

15 lessons left of 15

Finish every lesson to unlock the certificate. Each one ends in a practice task — do them and the final project brief writes itself.

Next recommended course Full-Stack Web Development Bootcamp