In this video, Emmanuel Henri demonstrates how to implement the code for updating the context.
- [Instructor] Okay, so the first thing … we're going to need to do to update … our contents from a nested component, … so we'll basically pass a function through our provider, … and then leverage it and consume it in this component. … We're going to need first, to add a few things … and refactor our code a little bit in our App.js. … So let's go ahead and do that. … So the first thing I'm going to do is create a function … inside of my constructors. … Let's go ahead and create a function that … we're going to call toggleName. … And this function will basically … take the setState function, … and take the state. … So basically we're going to check on the name property. … We're going to change this in our state in a second, … so we're going to leverage what we've done here with our user … and basically remove this and then create our name property … inside of our state. … We're going to leverage the name and then … do an if statement, … so this is basically a shorter version, … so the ES6 version of an if statement. …
- 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