In this video, Emmanuel Henri demonstrates how to create the first context object needed to work with context.
- [Instructor] Okay, so let's get started by … creating a context object. … So that's the very first thing you need to do … when you want to leverage or use context. … Let's go in to our App.js, first. … What we're going to do is create an object that will leverage … and has into our context object. … Let's go and create a user. … I will create some data inside of the user, … so let's do first name, … do "Manny". … And then last name, let's do "the last name". … And then let's put some data in there as well. … "This is some data". … Okay, now that we've created an object, … the way to use the context is to first create … a context object, and we'll call this one "User Data". … And the syntax to create a context object is … React, dot, … create context. … And you've seen in some cases people passing some … default value here, so if you want to to do something like … "light" or "cyan" or if you want to use this for … any type of data that you want to pass as the default data … you can pass it here. …
- Creating a context object
- Implementing the code for updating context
- Updating context from a nested component
- What to avoid when working with context
- How the node tree in React applies to context
- Consuming multiple contexts