In this video, Emmanuel Henri introduces the context provider and what it is used for with context.
- [Instructor] The next stage in working with a context … is to create the provider. … So, the provider will provide the context … to its children components. … So, the way to do this is do UserData.Provider … and the provider needs to have a value … and as you probably guessed it, the value will be … the user data that we've created in this object here. … It could also be something from the state. … So, you could do, for example, you could do the user data … inside of the state and then pass this.state.user … and we're going to do this later on … when we start working with updating our context. … So, for now, let's just do, user. … So, basically the job of the provider is providing access … to the data to its children components … and if there's any changes to it, … it's going to rely on the value here. … So, for example, if we had the user in the state … and, for example, we make a change to the state, … then this provider would update the value … inside of the context and then provide this value …
- 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