Grokking React Fundamentals
Vote

0% completed

​

Sharing Data with Context

A parent can make a value available to every component below it in the tree, at any depth, without passing it as a prop through each level. A component anywhere below reads the value directly. React calls this feature context.

The Prop Drilling lesson ended with a chain of four components. App knew the user's name, Child displayed it, and GrandParent and Parent received userName only to pass it on. This lesson removes that drilling with context, so you can compare the same app before and after.

The Same App with Context

Here is the drilled version again:

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content