← BYTES
React.js·Intermediate·Ref: 4.2.17

How do you read a value provided by a `Context.Provider` inside a function component?

Have a question about this video? Mention reference 4.2.17 when you contact us.

a.By calling `useState(MyContext)`
b.By calling `useContext(MyContext)`
c.Context values are only accessible in class components
d.By reading `window.context` directly
`useContext(MyContext)` is the hook that subscribes a function component to the nearest matching `Context.Provider` above it in the tree, returning whatever value that Provider currently holds.

Find this on YouTube & Instagram

Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:

#BYTES#BYTES4217#Reactjs