black friday sale

Big christmas sale

Premium Access 35% OFF

Home Page
cover of use context
use context

use context

chandan tor

0 followers

00:00-05:48

Nothing to say, yet

Audio hosting, extended storage and much more

AI Mastering

Transcription

The speaker discusses the concept of "useContext" in CS technology. They explain that "useContext" allows data to be passed from a parent to a grandparent without using any properties. They demonstrate this concept by creating three child classes and passing data from the parent class to the last class using the "useContext" method. They explain the three steps involved in using "useContext": create, provide, and consume. They provide an example of how to create and provide data using "useContext" and show how it can be accessed in the child class. They emphasize the simplicity and benefits of using "useContext" to pass data between classes. Hi guys, welcome back to CS technology today guys in this class we are going to discuss a use contents hook guys okay, so what is the use content and how to use that guys, so basically guys use content guys, so we can pass the data guys from the parent to grandparent directly guys without using any properties guys okay, so like as we have a many child right okay, we have a many subclasses here, so in the parent class guys we have a some data, so if you want to pass that data guys, so directly to the last class guys, so how to pass that guys, so this is a basically the concept guys for use content guys okay, so that is reason just guys I have created 3 child here, you can see that, so child 1 and child 2 and child 3 guys, so child 3 guys I have imported here, so that access the data guys, so child 2 guys I have imported here and child 1 guys I have imported in main class, so that we can access the data guys okay, so now guys for using a use content guys basically we need to follow 3 steps guys, one is create, second is a provider guys, you can just provider and third one is consumer, consumer is going to receive the data guys, so now we will start that guys okay, practically we will see that guys, so that we will understand more, so first thing is we need to create the data guys, so for creating data guys, I will be just creating here, so just I will take a product guys, I will just mention product, here you can write anything, I will just write mobile phone, so that is mobile phone, so guys now I have this product guys, so like it is a data guys, we need to pass this data directly to child 3 guys, how to pass that, so first thing is I informed you need to create that guys okay, so for creating guys, so you can take any name here, product create, you can just change this name guys, because already I have taken product here, so you can take data here guys okay, data, so create content already created here guys, so you can see that, see the first step is over guys, create, now guys we need to provide the data guys okay, so for providing guys, see here we need to take data, the variable name data we have given here right, so I have given data right, a variable name, so I can just mention data dot provider, so this is the second step guys, we have done that, now guys we need to export that, so once we export that guys, so all the class can access that guys, either child 1, child 2, child 3, anyone can access that guys okay, that is the reason I am just I am exporting data, a variable name data guys, so that is the reason I am mentioning everywhere data guys, see this is data guys, you can give any name guys as you want, but the same name we need to provide here guys, see guys now first step is over guys, created provider over, now guys where guys we are going to pass the data, we need to open that guys, we need to pass child 3 right, let us open the child 3 guys, so first step guys we need to first import that, we have exported data, now we need to import here, because I have imported, second guys now we need to use, use content here guys okay, you can take any name guys, you can give product, use content, so we need to use here guys, where we are passing the data, there we need to use that guys, so inside the array we need to pass the data guys, we have mentioned that guys, and also guys we need to provide value here guys, sorry I have forgot that, value we need to provide here guys, value the product right, we need to mention that, this one we need to mention guys okay, so here now guys, for displaying that guys, we need to, we can just take h1 here, we have received our, see guys that is it guys, this is how guys use content will work guys okay, we can see now guys, open the browser, we can see that guys, here we have received our mobile, so this is the data, we have received that guys, so this is how simple is it for using use content, now guys we have just taken the simple data guys, so we have only written one line of code, so we have received this data guys okay, directly we have passed into child 3 guys, so without using any properties guys, without touching any child 1 and child 2, directly we have passed that guys okay, in future guys, in live project, we might have more child classes, so in that guys, if you want to directly pass guys in the last class, so we need to use the same method guys, this is a benefit of use content guys okay, so that's all guys today class, for more videos guys, kindly subscribe my channel and follow my video guys, thank you, thanks for watching.

Other Creators