React · Junior · Question 32 of 75

What steps are needed to pass data via Context?

Explanation

const ThemeContext = createContext('light') → <ThemeContext value={theme}> (in React 19 you can omit .Provider) → useContext(ThemeContext) in any descendant. When value changes, all components reading this context re-render.

Further reading

Problem with a question

React · Junior · question 32

Test yourself

Take the React · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz