- Podcasts
- ReactJS Developers Podcast
- React Props Explained: Essential Concepts Every React Developer Must Understand
React Props Explained: Essential Concepts Every React Developer Must Understand
ReactJS Developers Podcast
- December 3, 2026
- 55 min
- Episode 17
About this episodeProps are one of the fundamental building blocks of React, but understanding how they work can completely change the way you build React…
- What props are in React JS and why they matter.
- How to pass data from parent components to child components.
- How to receive and access props inside functional components.
- How to pass multiple props to a component.
- How to use props to build reusable components.
- Understanding the difference between props and state.
- Common mistakes developers make when using props.
- Best practices for managing component data.
- Beginners learning React JS.
- Frontend developers improving their React skills.
- JavaScript developers transitioning to React.
- Anyone building reusable and scalable React applications.
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
React Props Explained: Essential Concepts Every React Developer Must Understand
Now I am going to explain you props in depth. Now you must be thinking that why am I repeating props? Component, GSX, props, etc. I am repeating again. So again I am saying the same thing. First I told you the basics. We have read the component in depth. We have read the JSX in depth. Now we are going to know the props in depth. Whatever doubts you may have, it will be clear now. Because I will explain everything. And all the possibilities can be in props. Whether you want to send an array, object, or pass it to children. We will discuss all those possibilities. You might have already done it. If you are a coder, you must have done it. But again, all these things are possible. If you are repeating, then definitely look at 2x or 1.25x. It will be fun. So, you will get a lot of extra things and a lot of things will be repeated definitely. But, crystal clear. Props are over after this lecture. And in the next lecture, you will see the data flow which is definitely useful in the interview. Alright. So, if I want to explain props in a simple way, then I had told you that a component is like this. You are understanding that a component is a UI. I have made it like this that you just understand that for now, this is your component. And what am I doing? Okay. This is your component. Now we can use the component in multiple places, but if we use it in multiple places, then definitely the same component will be seen, the same UI we have made will be seen, so if we want to change our data in it, if we want to send our data, then for that we have props. If we want to send some data from outside, inside the component, then we use props. So props is nothing but we are sending data. We will see how we are doing it now. If it has some data internally, then we call it state. We have already made some data inside, so we will discuss state later. So there is some data inside, you know the state component. If you want to send some data from outside, then we are sending props. We will receive props and use them. This will be your component. We have to send data in it. So we will send props here. And we will receive this props here. And we will use it there. Now how do we do it? It is very easy. It is very easy. If you have read the java script. I say that react is nothing. If you have done java script. Then react is nothing. Why am I saying this? I am saying this because you have read the object. If you have read it. I have been saying for a long time. That all these things who have not done. There is a lot of gap. What are you doing? Read Javascript. If you have forgotten, revise. People say that doubt is clear. Doubt is definitely getting cleared. But I forget. Or when I sit to code, I don't remember. The reason for this is that you don't revise. You don't practice code. You will become a coder only when you are coding. You will think that we have seen the lecture. Like you study in school, ABCDE. ABCDE is not ABCDE. Here if I am writing code ABCDE, then you have to do it on the computer. Only then you will be able to learn. and at least in a day, if you are going to college, then I will not say that 5-6 hours should be with you. But if you are not going to college, if you are at home, then definitely make a project for 5-6 hours easily. Because in making one project, I think 5-6 hours go easily in the sequence. So, okay. So, you can see the java script. And outside this source, you are listening to it. It seems to have come with smoke. Now it will be full of smoke. Anyway, let it go. I don't know if the sound is going or not, but I will calm down for a while. Alright. So, it has gone quite far. So, our object used to be like this. Here we used to write key and here value. Key and value used to be written in pair. For example, if I want to write name, then name and here value is minus in my string. Now, it is not that we can give string and it is necessary to put comma. Here I can also give number like age 21. I can also give boolean here. Is student. is student. So definitely, yes, I am also a student. So here true. So this is your object. Now what is props? Props, I just said, data is sending. So what are you sending? Properties. And properties, you know, in object, this one is, here we say the value of one, this is a property. This second one is name property, age property, is student property. So props is nothing but properties. This is our component. We will send the data. And we will receive here. Now while receiving, we will get an object. You can give its name to anything. You give the name props here. If you are reading props, then give props. Properties. Okay. Or you write the whole property here. or you can keep object as object because you are getting an object. Alright, whatever you give, it will be an object. The data you will send, you will get it in object format. Keep this in mind. Whatever data you will send from here, you will get it in object format. If you keep this in mind, then you will not get into error. I give you this much guarantee. Whatever data you will send, you will get it in object format. There will be a property in it. You can access it. That is called props. How to send data? This is the component and its name is COMP. How to use COMP? This is COMP. Now we have to send the name. I will send the key value pair in this way. The difference is that we do not use colon. We use equal to. And here we have MANAS. I have sent one key. If I want to send another key value, then I will not use comma by giving space. The method of sending is different. Receive will be in object format. Age is equal to 21. So, we have to put curly braces here. Tell me quickly why? Because we have to send JavaScript here. We have to write JavaScript, so we have to put curly braces here. However, we can also put it here in this way. String is also a part of JavaScript. So, you can also put curly braces here. But React says in string that there is no need. So, even if you don't put it, it will work. But if you are giving an integer value, then definitely you have to put curly braces here. Or if you are sending a Boolean value, is student. is a student, then here also you have to put curly braces in this way and close it in this way. So this is the way to send data in some component and the way to receive it is as an object, if you are getting properties in it, then you have to access it in that way. I hope you have understood all these things theoretically. Let's do it practically in the future and in depth, although that's why I told you practically earlier, so that if I am telling you all these things, then you can understand it properly. They are inputs to a React component. Okay? Any component definitely has inputs and data. You can understand this. So, I take the red pen here. I like this. Props allow you to pass data from a parent component to a child component. Look at this carefully. This is asked in the interview that from where we are making the data flow. Data flow, which is our next lecture, chapter. We will see in that. For now, We are sending data from the parent component to the child component. Like your parent component is app.jsx. If you have made any component in this, then this will be your child and this will be your parent. So we are sending data from the parent to the child. This is the way we are sending data from the parent to the child. But this is also a way that we can send data from the child to the parent without using any library or something from core react. This is asked in the interview. I will not tell you this now. I will not confuse you. I will bring a separate lecture on the data flow. I will discuss the whole data flow and tell you what to do from the point of view of the interview. So, the data that we are sending from the prop, we will definitely send it from the parent to the child. If your parent is app.jsx, then you will definitely use the component in it. So definitely you are sending data. So where did the data come from? You are using the component in app.jsx. You have sent your data from app.jsx to the component. It is simple. So this is a small thing. You have to take care of it. The rest will be clear in the next data flow. They are read-only. Immutable inside the child component. It is read-only. You cannot change it. Now let's do it one by one. Let's code it and see. Then it will be more fun. Okay. It is immutable. Immutable means that we cannot change it. I told you in JavaScript too. Okay. Let's do it one by one. Let's code it and see. And why do we need props? So definitely. In the project itself, I have made it clear to make the component reusable and dynamic. If we can make it reusable and dynamic, if we can use the same component everywhere, then what does it mean? The data should be different, right? Like we are making a user card. So will we give the same data to every user? Will we give the same picture to everyone? Not at all. There will be different data in everyone. So we can send that data here using props. Instead of hard coding values, we pass data via props. Okay? Now let's do some code and then we will go to depth. And I have not installed VEET here because there are some changes in VEET. I want to show you that. So you have to come to VEET.DEV here. You know all this. I will show you the changes. I have not explored much. But there are some changes in the installation. So I will tell you. now. See the starting process is the same. In the same way it is installed in a round shape. Alright. To see the next process, it should be installed. So let it be installed. And our net is crystal clear. I believe it is running. Yes, our net is running. Okay. So, I hope it will be done quickly. Rest, let's see. It's done quickly. Don't do like this. So, see, it's installed. Okay. So, here, my face is coming out fine, right? Great. I will give the project name as wheat. I want to use react. I want to use java script. I have selected it. Here is a feature called useRollDownWheat. A lot of things have been updated here. I have read that a lot of things have been improved in bundling and performance wise. And this is experimental now. So it depends on you. If you want to see then click on yes. The future default wheat which is powered by RollDown. You will get this option in the future but for now I will say no. I will tell you in the future if I get any updation. For now, you have to go ahead with this option. It is experimental and still running. Install with npm and start now. Here you did not get this option earlier. Now you are getting it. This means that You must have seen that we used to install npm i before installing cd. So this option is asking here that do you want to install with npm and also do you want to start now? So if you don't want to install and start, then do no. If you want to install and start together, then do yes. So this is a good thing. You are saving time. You do yes. It will also install. Also, there is no need to run npm dev. It will start by doing that. So It's interesting. Updates are coming. Alright. So let this install quickly. This install will be done. It shouldn't take much time. I don't know, sometimes there is an issue with the net. Yes, look, this is installed. And here this start is also done. So I will come here by clicking control. So our wheat application is looking very good. Just like that. Just like that. Wow. So here I am not installing Tailwind CSS right now. Because I just want to give you an idea of props. I will quickly clear all these things. This is clear. All this is coming to you. How to clear, what to do. Alright. Let's not do anything else. Let's move ahead. So I said I want to make a component. So I make a component folder here. Components. And inside this component, I make a component here. Car.jsx All right, R-A-F-C-E and here I make a small card and I will not do much in the card, I am just showing the name here. What did I say? I am just showing the name here in the card. And I give the class name card and for now I write here C-S-S-A, who will go to install Tailwind now? I just have to explain a little to you. So I make a card with dot card, I will give the padding of 30 pixels. It should look like a card. I will give border-radius of 30px. And you know how to use CSS. So, 20px border-radius. And give BG color light-green. Alright. I think it will look better. And give anything else. Nothing else. Alright. Here comes our last card. We have selected the card and given the style. Alright. And we are using app.css here. So, I had told you that it works globally everywhere. So it must be working here too. Now let's use this card. How to use? We have made this card component. I have told you how to use the card in this way. And it will be imported automatically. If not, then you can import it by giving path etc. Alright. So let's come here. See, we can see a card. Now there is nothing in this card. That's why it looks like this. In the card, we have to know the props for the time being. So we will know. But for the time being, I put a minus comma here. So this is our card. And we will increase the font size a little. We will increase the font size to 60 pixels. According to me, it will be very big. No, this is fine. So 60 pixels is enough. Let's close CSS. This is our card. Now, see, this card is made. But now if I replicate it here. So to replicate, see, this is replicated. Alright. And here a little tailwind. That's why I use it. You don't have to define classes again and again. So here I give it the name layout and I have to style it a little otherwise I will not be able to explain it to you crystal clear. What should I do here? I will flex its display, I will not do much, I will flex the display and do the flex direction column. So it will come as it was coming now, I will just give a gap here, one rem will come a little gap. So now our card has been made. Now see our card is made. But here all the cards we have used till now are looking the same. So what is the benefit of the card? We could not make it dynamic. We have to send data in it. Again I am telling the same thing that data has to be sent. So if data has to be sent, then how will I do it? Through props. I just told you what is the method of sending data. Here in the middle you have to give a key value pair. Like I give a name here. Name. And here I write. See in string you can directly give like this. Without curly braces. MNAS. k-u-m-a-r-l-a-l. So, here I have sent the name. Now, if you look carefully here, then you can receive here. Now, give props name here. Again, I have just told you, give props name, give object name, give properties name. It's your choice. Okay. What is in object? It is properties. So, you give object name here or give props name, give properties name, give anything. In maximum cases, you will get props here. I have given props. Now, I will show you this props that what is coming here. I have added data in the first one, so it is coming in the first one. The rest is empty. I have made multiple cards. Remove the strict mode in main.jsx. It will be seen here as many times as we have used it. We have used it 5 times or 6 times. So here we have added the data in the first one. So we can see the data in the first one. Here we have added name is equal to Manas Kumar Lal. So here we are getting in the object format. This is what I wanted to tell you. That no matter how you enter the data in the key value pair, you are getting properties in the object format. Okay. I will add one more here. Age is equal to 21. So can I put it here like this? No, I can't. Here I have to put curly braces in this way. Okay. Alright. So here we are getting age too. And if you put curly braces here too, then there is no problem. But here you have to put must. So here the name came, age came. In this way you can send multiple properties. That's why we call it props. Properties are nothing else. Properties, props. You are sending properties, you are sending props. You are receiving props, you are receiving properties. You are getting in object format. Alright. So here you are sending, here you are receiving. Where? In card component in this way props. So here you are getting an object. So you can also give its name object. This is an object. If I send it to another object, then you will get title object. You will get title object in the second one. Reload. You will get title object in the first one and name object in the second one. now what is the problem here, here I have done the name age and here I have done the title, you don't have to do it separately because you have only one component here, now the name will be coming in the first one and the title will be coming in the second one, then how will you work, you will take the title or the name, there will be confusion definitely, so here you have to keep it consistent, it is not like doing anything, if you understand the concept, then you just have to keep this in mind, I will show you how to use the object. I will use javascript. I will use curly braces like this. The object has the name property. So, object.name. Now I am getting object.name. It is not coming in the rest because there is no name in the rest. There is a title here. There is no name. There was a name here, so I got a name here. I want to send the rest too. I want to send the name here. Assume I want to send alpha. whatever is random, it will come in the second one. We can send whatever we want in the third one, whatever we want in the fourth one. Props is a way to make these components dynamic. Props means properties. Send properties, receive properties and use them. That's it. You should know the object. Object comes, that means props also comes. Do you understand this much? Very good. Let's move ahead. Okay, you got the basic understanding. Let's access the object by dot dot dot. Here also we will access the properties by dot dot dot dot. Okay. Destructuring props is a very important concept which I have already explained in JavaScript. It is not a part of React. Destructuring is a part of JavaScript. You can destructure the object. For example, in the object, if you have here, I will make an object manually to explain to you. Name manas and here I have given age 21. and not in this, I will tell you in main component, parent component, here in this place. So you will see it only once, otherwise it will come multiple times, you will get confused. So here if I do CLG, object, then you will see the object and also have to apply cost. the cost too. So let's come here in the browser. So see here you have an object and object is not defined at card. What is it saying? Remove it for the time being. And here the object is not defined. There is no problem. So, let me explain destructuring once. Here, see, name and age are coming. Now, this name and age have to be removed from the object and have to be saved in a separate variable. Listen to me carefully. I have already told you in JavaScript. It seems that you have not read it. See, object has name and age. So, if I have to access name anywhere, then how will I access? Object.name. Object.name. Okay? Object.name. Here, understand my point. Object has a lot of things. Name is How will I do it? I will erase it quickly so that you get crystal clear notes. So how will I do this? So definitely there is an object here. There is an object here. There is nothing much to destructure this object. What? Put curly braces. Put curly braces in the object. Put curly braces here. And pass the object like this. So this object is coming here. This whole object is coming here. Now you have to find the name in that object. You have to find the name. You have to find the age. You have to find the age. If there is nothing else, then what else will you find? keep in mind that if there is a key, then you have to give the name and if there is an age, then you have to give the age, you can also give it at the front and back, there is no problem, you give the age at the front and give the name at the back, the key should be the same, it will extract you, you can say that you are extracting, here you will get the age, now you do not need to do object.age again and again, here you see the age has come out, if you want to use the name, then you can simply use the name in this way, so this is your destructuring, the object is coming, to destructure, we have put curly braces here and we have removed the keys inside it, okay, We will use the same method here too. We have sent the name as and removed the card below. We have sent the name and age. We would have been getting an object here. But we don't want obj.name and obj.age from the object. We just want the name and age variable. So we have to destructure here. We will put curly braces and remove the name and age from here. We haven't sent anything else, so we can't remove anything else. Whatever key you used here, use the same key here. Otherwise, you will get an error. We will take CLG here, name. And here CLG, age. Now we can use it differently here, like this. See, name age is coming. So we don't have to do anything here. So we can do it in the same way in maximum places. Rest, that method is also correct. You can do it in the same way. But this method is much better. Let's make an h1 here and wrap it with a fragment. Otherwise, you will get an error. So name and age. Okay. So whatever you pass here, name and age, you will see that name and age here. Okay. Why do we see different? Why do we see different? These two things are in the same card. Okay. We have given two classes here. Wait a minute. Let's div this and make its class name card. and remove this card from here we don't have to keep these two different cards so this is the name and age in the whole card so now see this is our A card ok our name and age is coming in one card and I think I have zoomed a little no ok so this is our A card now here you will send data as many times as you want like here if we are sending Muskaan in name then Muskaan will be sent and age we are sending 19 here, 19 will come here, see, minus kumar dal, h21, muskan, 19, okay, in this way, so you, sorry, in this way, you can use it by destructuring here, and we are using it by destructuring at maximum places, and there is one more feature of destructuring, the feature is that you are getting suggestions here, if you are using a card here, in this way, here you will get suggestion, enter control space here you will get suggestion, age, name and key, key comes by default if you are doing map then definitely you are sending key, so key comes by default don't pay attention to this, age and name ok, if you want to receive something else here like I want to receive some student name key here now that matter is different that you are sending from here or not but I want to receive here ok, so here you will get suggestion that this card is receiving the value of age, is receiving the value of student, and is receiving the value of name. Now it is your choice, you send age, is student, don't send name. It is possible you send name, is student, don't send age, or don't send all three. It is your choice. But here you are receiving all three, so you are getting in suggestion also. This is a good thing about destructuring. If you don't do destructuring, normal, normal, you will make obj, like this, obj, object or props like this. So if you look at the suggestion here, then you are not getting any suggestion here because you are not restructuring and receiving here. So if you send name muskan or age 19 here, then it will come under an object and then you will have to do something dot something something dot something and access it. So what is the better approach? What is the production approach? That you can send any key value you want like name, age, student, So this is a better way, so that if any other developer is working and he wants to use your component in this way, then he will get a suggestion here that this component is taking age, student, name, that's it. And we send the key when we are mapping. So this is a good thing about destructuring. So I hope you have understood so much. And after that, we have basic understanding. De-structuring is done. This is a much cleaner way. And props are immutable. That means we can't change in props. After passing in components. So we have passed name and age in components. Now if you want to change here. Like, like, like. We can change in object definitely. But in components, props which we are ending with. Props. It is like object. We can change in object also. But we can't do it here. Because these are properties of props. Props have a different name. You could have changed the object in this way. Let me tell you in a normal way. Props is coming here. So props.name is equal to minus. It could have been if it was a normal object. But here we are sending props. Component is a funda. React is a funda. So here it says that it is immutable. We cannot change it here. This is what it is saying. I am not saying this. This is what it is saying. Okay. so this could be due to syntax error let's see what is the syntax error what is the syntax error bro? we have put a comma I am so sorry so we will reload here cannot assign to read only property name of object we cannot change in read only property but if it was a normal object I am also revising your javascript If it was a normal object with some name, you could have changed it here. obj.name is equal to, if I change minus to Muskaan, you will see Muskaan here. I do CLG to the object, so you can see Muskaan here. We can change this to a normal object, but we cannot change the object that is coming here. It is immutable. There is only this much that you have to keep in mind. You can also be asked in the interview. That's it. So this was our basic of props. which I told you a little earlier, but I gave you some extra understanding. And now let's move on to all possibilities. Now see, your props were up to here. As much as I just told you, your props were up to here. That's all there is in props. The measure that I told you that You have props.com.properties, which is like a normal object, which is sending data, which is receiving data in properties and object format. This is an input for a component, so we can make it dynamic, reusable, and send it from parent component to child component. It is read-only and immutable. These are the props. Now I am discussing the possibilities. You will not get to see this extra anywhere. just for understanding that if we get stuck in making a project in this possibility like if we want to send an object then how will we handle it many people don't know so I am telling these possibilities if you don't want to see any possibilities then there is no problem your props were till here if you have proper understanding in javascript then you can definitely send an array in it if you get a different one for children then I will say for children, you can see how will you send an object and I have already told you about number and string So, I am telling you different possibilities. Nothing else is different. Props were the same. The rest is the data flow. We will discuss in the next lecture. So, we have to send the basic props like string, number, boolean. So, I have told you all this. by destructuring you can use it in normal way now what is this? this is conditional rendering I will tell you this in the next videos so don't pay attention to this rest normally you have this much here ok? props as object now I will tell you this many people get stuck here they get stuck because because Here I told you that you can send properties. Okay. Now it is not necessary to send string or number in properties. It is possible that you send only one object. So what will happen? So let's see. I told here the cost object. Made. Name. Minus. And age. 21. Made an object. Oh I am so sorry. Here there is a colon. So I made an object. And it is possible that I want to send only one object here. And I have given the key of that object. Assume I have given the key of data. And I want to send this whole object inside this key. Then what will happen? Then nothing much will happen. The same method is still the same. Nothing different. I am commenting here for the time being so that there is no error. You can console here and see simply. Whenever you are confused, you can console and see. Now I have sent the object here. Earlier I was sending the string and was sending a number, so it was coming in a combined object. What will happen now? Nothing different will happen now. The object will come inside the object. Understand? I am sending data, I was sending a number, so the number was coming inside an object. And I was sending a string, the string was coming inside an object. Now if I send an object, then the object will come inside the object. Okay? Try to console it. It is very simple. Try to console it. Look, this object, inside the object, our key value, data, and what we have sent in that data. That's it. Nothing different. That's why I said that your props are finished. Nothing more than this. If I want to send another key of this student name, here I send a true message, then see here, you have two keys in the data. The first data contains an object, the second contains a boolean value. Alright. So you can destructure it here. Definitely. How will you do it? I will tell you now. I am so sorry. Here you are sending the data in this way. Here you can do destructure. First was your data. So first your data happened. And then after that is student. So this is our destructure. And now you can see here you have different data. Is student is coming separately. We have done destructure. Reload. And there is some error for now. Okay, our object has been removed here. Okay. So see this. our object is different and this value is also different it is coming undefined in the other one because we haven't sent anything in the other one now if you want we have de-structured in this object now we have de-structured this data object also in this object so you can definitely do it how? you have sent name, age here in this way name comma age nested de-structuring I have taught you in javascript so name comma age and this should also be de-structured but here it is creating some problem I don't know why you can't do de-structuring here name comma age I think you can't do de-structuring here so here you have a way to do it in this way const name comma age and here you have oh man write it properly data ok So, this is your destructuring. You can't do it here. No problem. We will do it here. We have read JavaScript. It is our wish. Okay. CLG, name, age, and isStudent. All of them are in your variable one by one. So, now you can use it easily. Look. This is name, age, and isStudent. Okay. Cannot destructure property name of data as it is undefined. Okay. It is saying for the other one. We have not sent data in the other one. So, it is giving error for that. Okay. So, so many things are clear to you. If we send an object, how will we handle it? And if we send a string number and a boolean, how will we handle it? Alright. Then we move ahead. If we are sending an array, then definitely handle it in the same way. Nothing different. This is your homework. You do it yourself. Like we were sending an object. Object was going inside object. This time if we send an array, then our array will go inside object. And that's it. And our charge is over. Good that I saw it. Otherwise, it would have stopped. Okay. So we have an array coming here, not an array, an object that is coming to us, first we have destructured the object, now you will have an array in it, so we have mapped the array, all these things are coming to you, so try it once, you will get an array, how to use it, map it, do whatever you want to use, this is your homework, look at the array, props as functions, what is this, props as functions, can we also send functions, Definitely. This is an interesting thing. This is an interesting thing that you can send logic too. Exactly. You can send logic too. This card one is ours. Let's leave the card as it is. Let's make a new component. I will make a button.jsx. Button.jsx. And in this button, I will quickly make a button. A small cute one. I will give the name of the button here. I will give the button tag basically, then it will be automatic style. Why? Because we have not deleted the style here yet. In index.css and app.css, by default, some styles are made. So, according to me, the button has been styled. And here we will receive some title. Now you know how to receive. So I will use the button here. So I must be getting suggestions that I want to receive the title here. Alright. So, I will give title as click me. Okay. I have given title as click me. And here we will also use title. Title. Alright. So, we have made a button component. And here in button component we have sent props. Props. Title. Okay. So, here you have a button. Here click me is coming. I will use one more button and give its title. Dabu Mujhe. It is not looking good. Dabu Mujhe. It is looking a little different. Okay. not Dabo, let's give something else. Push me, no. It looks a bit like a tharki. Let's give click shift. So click me and click. We have two buttons. We are sending different data in both of them. Definitely, we are making dynamic components. Alright. I want to say here that we can send functions too. Alright. How will we send? First, let's make a function. I made a function. I gave the name of the function click1 or button1click. button one click I made a function and here CLG is doing that button one click has been done by people and this button one click we can send here ok so can we really send? we are not getting suggestions because you are not receiving here ok so you send first then receive or you receive first then send what happens is that you get suggestions there so there is less chance of spelling mistake So I usually do this, first I receive it by destructuring and then I send it back. So I get suggestions. Spelling mistakes are less, error is less. So after the title, I want to take a function here. I give the name funk. Funk. Any problem? I gave the name funk. Now here funk will be taking this. So we will send the button one click function in this. So will this button one click function be coming? Definitely coming. How will we use it? You tell me how to use it. Here onClick is written like this, right? Tell me, man, I have read all this. OnClick is written like this, yes. We send a function in it, yes. A function is coming in it, yes. This is a function, yes. So send it here. Okay. Wasn't there anything else? No. Simple props. A function was coming here. You passed this function. Normal. Like if you had to send onClick here, then you would have passed this function. Now this function of yours, you are sending here. So you are receiving and putting it here. Will this function work? It will definitely work. Why will it not work? Look at this. We have sent the function on the first button. So by clicking on the first button, the first button is clicking. Nothing is happening on the second button. Look at this. I am clicking. Really, I am not lying. Look at this. I am clicking. But it is clicking. It means that nothing is happening here. This function is not working. Because we have not sent the function here. So for this, you can make a separate function. So definitely you can send the function. The main thing is that you can send the function. So take the suggestion here quickly. And I sent the second function. There is nothing to change here. Once you have made the component. Here you keep changing and sending. If you have dynamic, then keep using it. If I am clicking on it, then the button 1 click is coming. This is because we have written only button 1 here. I write button 2. So if I am clicking on it, then button 1 is clicking. If I am clicking on it, then button 2 is clicking. It's happening, isn't it? Yes, it's happening. Okay, you understood this much. And props as functions is done. Clear, I believe. After that props as JSX. This one is also your homework. There is nothing much in this. Look, here we are sending some HTML elements. Basically, what is JSX? Do you know what JSX is? If you are writing something in your tag, I have told you. Go and see. You know JSX. You can send JSX too. That's it. P. you. I will show you. What will you remember? I will show you. Let's say I want to insert my JSX in the card. So I give the name of JSX. I give the name of content. It looks good to see that they are putting some more content in it. So, this name and age must be coming here. Okay. And they are adding some content of their own. So, how will we add this content? Obviously, in this way, curly braces open and close. And this content, you know, if you have to insert something anywhere in JavaScript, then curly braces open and close. This content. Now, this content, because I have used it here, now I can definitely send string value in this. I can also send number. If I want, I can also send the whole JSX. I will send it and show you. See, I am getting suggestions of content. Now, in this content, I will I will send an h1. Hello. And along with that, I will also send a paragraph. I will also send a paragraph. Okay. Wrap it in a fragment. Otherwise, keep it like this. So, it will look good. And if it looks good, then it will look good. Okay. Paragraph. Lower m 20. So, see this. I have sent the whole HTML in it. So, you will also see this here. See, minus and this 21 was coming from here. and then hello and this whole paragraph I have also sent then you can do this too. You can do a lot of back-ups. You can do a lot of back-ups in react. Ok. So, did the voice change? Props as children. Wow. Now this way is also good. See, as you were sending content here, if the content call comes and again our camera is cut in the middle. You try, sometimes when the call comes, the video is cut. Ok. I am not lying. When the call comes, the video is cut. Trust me. So the call came and the video was cut. So I was telling you that the way you are sending normal HTML content. Now see the content is like this. If you are sending as a prop, then the content is not getting caught. Content gets caught when we are sending something like this. Like, like, like, wait a minute. Like, I wrote H1 here. And if we write some content inside this H1, then we feel that we are writing content. Think, think. If we got content to write like this, that you send content like this, h1 and props like this. It's not fun, right? Writing content is fun when something like this, a tag has come, our opening tag, closing tag and writing content in between. It feels good. It's fun. So now how can we do that kind of work? I'll show you that. I'll make another component. In component, I'll make layout and in layout, I'll have to give L capital. layout dot layout.jsx ok this is our layout.jsx rafc rafc and here now you don't have to do much do something like this do something like this I will show you I will show you I will show you this is props ok and I am consoling these props here ok alright and will I comment all this for now any problem if I comment I don't think you should have any problem Now I am going to use layout. And it will be imported automatically. Now if I send title in this layout. Hello. So you will say what is the big deal. How many times will you tell the same thing. Here we have title hello and object. But now I am going to tell you something new. If you want to use it like a tag. You can do it. Exactly. If you use it like a tag and instead of sending it here, you are sending something here. Like I am sending hello in an h1 tag. Then see what you will get. See carefully what data you will get. See, title is coming and children is coming. Title is coming and children is coming. Title we have sent here as a props. And the rest, whatever children we are passing here, inside this tag, see. Whatever we are passing in the opening and closing tag, it is called children, right? This is a parent, there is a children in it. So whatever children we are passing, it automatically reacts. See how fun it is. It is automatically saying that I am a children. And as a children, it is taking the key and the value whatever we have put in it, that value is coming to you. See, the whole HTML is coming here. Isn't it interesting? Isn't it interesting? Again, see what I said. I said that normally you should What did I just say? I didn't understand. I said, normally you use it like this. Not like this. This is a tag. Normally you use a component like this. And here you are sending props in key value pair. But I said, you can make a component like this too. If you write something in between, then it will be going as a children. And you can use it. That's it. Okay. So I can send props here too. I can do it here too. The difference is, if I do it here, then the name of that key will be fixed. Children. I can't change it. Children. Okay? Children. Alright. So, here you have props.children coming. So, I can show that children here props.children. Really? Yes. See this. I have not sent anything in layout. Nothing. Nothing. Empty. Now, I will send hello in layout in h1. Do you see? I passed children. Children. Children. Children. Children. If you want, you can write by destructuring. See, you have to give the name of children. You can't change it. You can't change it. Children. And if there is any way to change it, then tell me. I haven't done this much experiment yet. That I will do something somehow. Here if there is children, then there is children. Okay. So children. If you want to receive something else, like title, then give title. And give full name. So if you are taking children here, then you have to take children from here. If you think that we should take children from here like normal props. So, can you take it? I don't know. Let's try it. I am trying it today. Can you give children in this way? H1. Hello. So, I have used children here. Now, I don't have to do it in this way. Here, I have to write normally children. So, let's see. Can you pass it in this way? No, you can't do it in this way. See, I told you. Props is not defined. If you want to pass children, then children will not pass from here. Children will pass from here. H1. Hello. Come on, bro. What happened now, man? Okay, was he giving this error? I'm sorry. I'm sorry. Again, I'll show you. I jumped a little too high. Okay, here again I pass children. Don't go, or else I'll be humiliated. I'll be humiliated. Look, even I don't play this much in development time. It's working, wow. Okay. But if you want to send something here, then your children are passing there. You understood so much, very good. And here you can definitely do it that way. But you will also use this method in many places. I will use it and show you. We make buttons in the same way. I will show you this work in the button. we were sending title here click me now I will not send title like this I will close the card and layout I will not send title like this I will take title as a children ok if you write spelling correctly then it will work well children and here you have children now see carefully how I will make the button now I will not make the button like this I will make the button like this I will make the button like this and here I will write click me and see here clickme is coming then again I will make one more button like a button button like a button ok here I will write click see click is coming like this you can pass children and if you want to pass function then here you can definitely pass func alright you must have understood this I am hoping like this and still it didn't come so definitely there is some mistake somewhere or you are not studying properly or If there is any problem from my side, then definitely tell me. What is the default props? I will tell you the default props. Default props are also very interesting. Like in the function, you have a default parameter. If you don't send the parameter, then the default parameter is taking you. In the same way, you have default props here. You have default props. Let's experiment on the layout. Let's make one more component. Let's give the name of this component component. component.jsx rafc Okay. so here I am taking title and age and here I am showing title in h1 and here I am showing age in h1 no problem I don't think there should be any problem I will use the component here it will be imported automatically if I send title as hello then here you can see hello if I don't send hello here If I didn't send hello here, then you won't be able to see hello here. This is obvious. Now what am I saying? I am saying that you can also give default value here. Default props. Default value you can give in this way. Title I will give here. Title I will give here. So if you have If you don't pass the title, then you will get the result. If you pass the title, then you will get the result. you can also give default value as default parameter in the function you can set the default value in the same way default value is 20 if you change the default value then it will be 20 but here default value is 20 there is one more way that they have given you can also do this way you can define the default value in one place how? like this I don't even know the syntax write the name of the component Default values and do it like this. Let's do it and see if it is right or not. If not, then you try. Here component dot default. I am not getting the suggestion. Default props is equal to the rest of your key value. The name of the key value is the title and I want to give the default value here. I want to set the age to 20. See, I set the default value here. I don't do it separately like this. So, I don't care about this. But I thought I should tell you, so I did. So, I'll remove this for now. And I'll remove this too. Let's see if the default value is set or not. Dhimka is coming. It means it is not set. Okay. I gave Dhimka in the title. If I don't give the title, then nothing is coming here. Oh man! I didn't like it. As far as I remember, when we use the class base, then we give it like this. So you have to see it. You have to see it. You have to tell me how to write it here. Default props. Default props. You can define default values if a prop is not passed. Default. I have to write default. Default. Default. Props. P-R-O-P-S. Props has P-R-O-P-S capital. And here we have a button. All right. level click me curly braces very good title title age I have done it right I think it is like this in the class based component here I do it like this so remember this fruit this is much better rest you see if it happens then it is ok otherwise there is nothing to worry about this way I have not done it yet in the class based component but I know so much that in the class based component it has to be done in the same way something like this happens ok so you understood this if you don't do anything now So you will get default values here. Alright. And here I will also give that example which I have just given here. This one. Ok. I will put this here by changing. We are reading functional. So I will put the functional one. Spread operator for props. Now I will tell you this one too. After that there is nothing. I have to say thank you and finish. So pass all props at once. If you have to pass all the props together. Like here you have to pass title and age. So if you have an object of title and age. Like obj. const obj is equal to title minus and age 21 and this object is already made somewhere here so I will remove this one so this object if you want to pass here like if you want to pass title then how will you do it here you will do this way title pass because an object is made above so obj.title will do this way so it is better that you use spread operator here and you know the use of spread operator you are here at the end it is converted into an object so make an object like this and do dot dot dot obj so the whole object will be passed so this method is also better make an object and pass the whole object like this you will get the object here you have destructured it and you are using it it will work ok so using this spread operator you can do it in one go if you want to send an object there is no problem And if you want to do it this way, then you can pass it this way too. This will also work according to me. Name minus age 21. No, not like this. Here the dot dot dot syntax only works. So you have to see syntax wise. Nothing is written. I have told you all these things by looking for it. I have not written anything. I do development like this. I find it. I do development. That's it. Ratna is nothing here. If you go to ratna, nothing will happen. Like I think this one is wrong. Syntax error is coming. Unexpected token. That means this is wrong. Rest you can google. Dot dot dot. By making object separately. This way you can send object. And normally you can receive and work this way. Okay. So for now that's it. That's it for this video. Then we will meet in next lecture. And I will try to prepare sorts. Time becomes an issue. You think I am giving an excuse. Understand it as an excuse. I think it is an excuse too. I can work a little more. But I am not doing it. I will do it. I will complete everything. Don't worry. Very good. So this is done. Alright. See you in the next lecture. Till then, bye bye. And in the next lecture, we are going to do data flow. Okay? So, it is very important from the interview point of view. Okay? Bye-bye.
