From the course: React: Components, Context, and Accessibility

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Understanding the context API

Understanding the context API

- [Instructor] In React applications we create nested component trees to compose our user interfaces. In early React apps sometimes you'd see state everywhere. This made it really easy to get some data quickly, but having state all over your app made it difficult to keep those values in sync. The common ideology then became, hey, instead of putting state everywhere, let's only put it at the root. Then we can pass down state data to components via props. So this starts out fairly straightforward. We can create a parent component that renders a child component. Let's go ahead and do this. So here on line 11 I'm going to create a component called resort. This is gonna have some state, which is just the name of the resort. And then we're gonna render something. So let's render a div that just displays that name. All right and then we're going to go ahead and render this resort. Perfect. Next up let's create that child…

Contents