Podcast Lookup

Build a COUNTER APP in React JS FASTER Than You Think _ React Pe React _ #6

ReactJS Developers Podcast

  • December 3, 2026
  • 46 min
  • Episode 24
Episode page
About this episodeWant to understand React JS state management through a simple, practical project? In this episode, you'll learn how to build a functional…
Want to understand React JS state management through a simple, practical project? In this episode, you'll learn how to build a functional Counter App using React.The Counter App is one of the best beginner-friendly projects for understanding how React manages changing data and updates the user interface. You'll explore how to use the useState Hook to increase, decrease, and reset a counter value dynamically.This hands-on tutorial will help you understand the relationship between state and component rendering while developing practical React skills you can apply to larger projects.What You'll Learn
  • How to create a React JS project.

  • Understanding React functional components.

  • Introduction to the useState Hook.

  • How to declare and manage state variables.

  • Updating state when a button is clicked.

  • Implementing increment and decrement functionality.

  • Adding a reset button to restore the initial value.

  • Understanding how React re-renders components when state changes.

  • Handling user events in React.

  • Building a simple interactive application from scratch.

Who Should Watch?
  • Beginners learning React JS.

  • Students practising React through mini-projects.

  • JavaScript developers transitioning to React.

  • Frontend developers strengthening their understanding of React Hooks.

  • Anyone interested in building interactive web applications.

Transcript

From the publisher

This transcript comes from the podcast’s own feed, shown as the publisher wrote it.

Build a COUNTER APP in React JS FASTER Than You Think _ React Pe React _ #6

00:00—
  1. Speaker 1

    Now we are going to make a very nice counter application. We will make it using ReactJS. I will not say that you will get to learn many things. But we have read many things till now. We have read many basic things like JSX components and props. We have taken basic idea of how it works. So that you get the understanding of React. Now we will be able to make this project using that understanding. and you are also able to make it, then you will get proper understanding of how data flows and breaks in components. Our first approach will be to make the whole application in one file. Then I will show you the second approach, how we can break the same file and separate it into components. separate the components and make the whole application. So this is the proper understanding of react. Not very proper but you will understand the basic project of react. First understand what is the counter application doing here. Here is a heading, no problem, we will give it by HTML. Then here you will give counter count by using any paragraph or div. But here if it is zero, it will be updated. If we click on increment, it will be incremented by one. If it is zero, then it will be one, then it will be two, then it will be three, when we will be clicking, then I will show you that I clicked on increment, it became one, then I clicked on increment, it became two, then we will do increment here, see here directly increment is happening and the feeling of the app is coming, just like you use the app, then the feeling is coming, just like the feeling of the app is coming, then as soon as we will do decrement, see here decrement is also happening properly, we will reset, then it will also be reset, So, this is a basic application and we will not go into the depth of how it is working internally. We have to understand the flow of react. Listen to me carefully. About 7-8 lectures will be basic. After that, we will start going in-depth like we did in JavaScript. We will do the same here. So let's quickly make this application. So you must have understood that you have to take a heading, a small div. And then there should be an increment when you click on increment, there should be a decrement when you click on decrement, and there should be a reset when you click on reset. So we understood this much, let's quickly make the application. Let's start. So, I have opened my VS code. You also open your VS code. And the folder in which we were working. You must be knowing. We were working in the react folder. Okay. I have arranged the folder structure properly. In the first lecture, we did this. In the second, this, in the third, this, in the fourth, this. Our fifth lecture. In that, we are going to make a beautiful application. So, what will we do here? We will make another folder. We will give the name counter app. Okay. So, the counter app is made. Okay. Now open your terminal in react. How I open my terminal? Control back cute or back ticks. Press control back ticks and it will open. First of all come inside this folder otherwise it will be installed outside. First of all, you have to go inside this folder. I will press the CD05 tab and it will automatically take whatever you want. It will take automatic suggestion. So, we will enter the counter app. So, we have come to this folder in react. So, whatever work will be done now will be done in this folder. Alright. So, what we have to do first? First of all, we have to install react. Yes, you said the right thing. First we will install react. So, to install react, we will search for vid.js. Why vid.js? I have told you everything. So, come to the site of VEET.JS. Click on get started. Come to the site of VEET.JS. Click on get started. Come down a little. Not much, a little. See this. Here you will get this command. Keep the select of NPM. And you will get this command. NPM create VEET at the latest. If you want, you can remember. But I don't remember. Although this is remembered. But still I copy and paste from here. It has become a habit. So I have done this copy, here I will come to the VS code, here I will do paste, enter, I have told all the setups properly, so now I will not tell again and again, in 2-3 lectures I am telling this only, so I have given the name of the project, ok. And here we have selected the React framework. What variant do we want to use? Javascript, definitely. We will also learn TypeScript, but now we are doing Javascript. So now it is telling that the installation is done. Yes, it is done. The app folder has been created in the counter app. The app folder is not looking good, so have you not used the VS code before? Look at this, it is not visible that the app folder has been created here. All these things are inside it. I am making another folder for now. Now you can see that there is an app in this counter. So whenever there is a folder, a slash comes here. So now you can see that there is an app in this counter app and there are all these folder structures in it. And we have understood all these folder structures. So now we have to run the app. First we have to go inside the app. It is saying that you can go inside the app using the CD app. So we will also come inside the app by using the CD app. Then it is saying that you can install the packages by installing npm. You can install the packages to run this app. So we will also install using the npm install. We are doing as it is saying. Alright. Then it will be installed quickly. It will take some time but it will be faster than CREATE REACTIVE. It will be done but look at this. Node modules, package.json, package.log.json is done. Very good. Now what to do? You can run from npm run dev. NPM run, can we run it from dev? Yes we can. Is it done? Yes it is done. Copy and paste this link on the browser. And then you can see the whole thing in the browser. And directly you will also do control click here. See this. It is asking you to do control plus click for the follow link. So come here, press control and then click on the mouse. And it will open. See this is open. And I believe it opened twice. This is our application. We will make our own application. Where to come for that? Main engine folder is src and app.jsx. app.jsx, this is the logo and everything. I will hide it. Don't kill it. If you kill it, then the react app that is running will be closed. So hide the terminal here. So here you can see the logo, vid plus react, everything is written here. Do you want this? No, you don't want it at all. Remove everything from here. What is this? This is a fragment. There are many things in JSX, like I haven't told you many things yet. So, I want to tell you in a separate lecture because I want to go in a little depth. So, I want to bring a separate lecture on this. And in the starting, I told you all the basics so that you can get a proper understanding. This was ours, Basics of React, Lecture 4. Proper understanding was given. So, I discussed all the things in it together. So, I believe you must have understood. And if not, then do not take tension. We will read everything one by one in depth. So what is this, tell me this and move ahead. So I told you that the return you do here is a component, basically a function. If you return in the function, then you will be able to return only one thing at a time. Either you return h1, or you return paragraph, or you return div. You can return only one thing at a time. If we think that we will return h1 and paragraph in the next line, then this will be wrong. We can't return two things at a time, we can only do one thing. For that, we have a method. The method is that you make a div here and wrap these two in the div. We did not wrap properly, these two elements have come in our div. So now this is the same element by law. Yes exactly. So we are feeling something like a deception. That if we put these two in one element, then this is accepted. Actually, it is like this. You have read HTML. These two elements that you have made in this div, this is your parent element and this is your child element. Right? Okay. So now this is the same element. This div is the same element that is returning from here. Alright. So whatever you will do in this div, you will see it on the side. Really? Yes. Yes. Okay. What was the fragment? Remove this div here. This react says that if you don't want to use div like this. Basically, you have to return only one element. So you don't want to do div like this. If you don't want to use any element then you can keep it as a fragment. So this will also work. Ok, does React allow this? Yes, it allows this. We can do this. Ok, very good. We can also do dip, no problem. Can we keep it like this? Yes, we can keep it like this. So whatever we write in paragraph and h1, like hello, we will see this hello here. Wow, whatever we write in paragraph, we will see it here. So we got a little understanding that it is like this. write in app.jsx will be visible there. This is not being used. This is not being used. And we are not using this count set count. Although we have to do this. We have to do count set count. We have to make counter application. So, we have to do count set count. But we will discuss this. We will discuss this. Now remove it. Now we have removed this. So, this is also not being used. Remove this too. It is removed. Very good. Now we have to make a UI and for that I am not going to use CSS separately. Why? Because CSS is already available in Vite. For now, we will do this. For CSS, I will give a separate lecture on how you can use CSS. You can use it in an inline way by using style attribute. You can also make a separate CSS file, like HTML, CSS. You can also use Tailwind CSS. So there are many things to style. There are many libraries too. We will discuss that. Now we don't have that main topic. Now we have done the style and if there is any need then we will come to app.css. You know that we will give a class in html. Here we will select the class and do the style. Now we don't have to do anything separately. We will do it in app.css. And whatever style is there in index.css, I have left it as it is. I am not removing it. And that's why you can see it in the black background. If I remove these two then it will look very ugly. So for now it is coming in the style. So I will give it here in h1. What should I give? What to make? What we have to make? Counter application. So, this is our counter app. Is it done? No, this is heading. Now, what we have to do below this? Take a div or a paragraph. Here we will mention count. In the starting, our count will be zero. See, what is the count? Zero. Let's zoom in a little. Very good. Then we will make two buttons. Let's do the format too. It will look beautiful. and here button so button button button will be the first increment increment and see I did not style in the button but see this stylus button is coming wow wow so this is also good ok so there is no problem rest you have to do your style, you will do it, there is no problem, I will teach that too, for now, you can see here how it works decrement ok so this decrement button came after that we need one more button and we need that button Which button we need? Reset. Ok. We need reset button. Ok. Increment, decrement, reset. Increment will be incremented. And decrement will be decrement. Means it will decrease. And reset should be zero again. Ok. So this is very good. It is looking very nice. Yes. We can make it a little more nice if we put icons here. So we have not learned icons yet. So we will not do that. Let's put emoji. Ok. Emoji. Emoji. So, how you will put emoji here? Window. I believe this is the shortcut in window 11. I believe this is the shortcut in window 10 as well. So, whatever you are using in window 10 and 11. So, you will see a button of windows here. So, window dot. The dot will be there in the angular bracket. The dot you put is basically this dot. So, window dot. You have to press the window dot. Here you will get the icon. See this plus icon. Then after that, this minus one, you will not be coming directly here because you have not used all these icons before, like I have used a tick, this kiss, I have used all this, so here I can see it because I have used it again and again, you will not be able to see it, so how will you bring it, then you have to search here, plus, you will search plus, plus will come, add will also come, then here search minus or subtract, then your minus will come, then after that come here and now how will you bring the reload one, For reloading, I think it will not be reset, it will be reload. So use this one, use this one, I will do this one as per your wish. So now see how beautiful it will look. Wow, now it is looking a little beautiful, it is looking good. But it is looking a little sticky. it is looking like that, so let's do one thing here, let's make a div and here class name class name yes class name in html you write class in jsx you write class name, one more difference came to know what came to know that you do not have to write class here, you have to write class name ok Class name and class are the same thing. Yes, it is the same, but here we write the class name in JSX. Ok. So in the class name, I give its name. Buttons and these buttons come here in app.css. With the dot button, as we do in HTML and CSS, I have selected it with the dot button. What will we do here? We will give display flex. Display flex and it is coming in the same way, but now we can also give a gap here. So we will give a gap. How much gap should we give? 5 pixels. 5 pixels or we will give a gap of 1 rem. It's looking good now. It's looking good, isn't it? It's looking good. Okay, so if we click on increment now, will it be incremented? No, where is the logic written? It will only be incremented if we click on increment, right? When we will write the logic of increment. You are right. So remove app.css here. And increment should be incremented. Now listen to me carefully. If this HTML, CSS, JavaScript was normal, So what do we do there? We make a span tag here. Then we go to JavaScript and select it from document.getElementById or any query selector. Then you select this button from query selector. Then we put event listener. Yes, we use event listener. Which one do we use? Click listener. Yes, click listener. Then what do we do after clicking? We take out its inner text. Yes, the inner text like 0, 1, 2. We take out the inner text. Yes, you are right. We take out the inner text. Then after that, we convert it to number. Because if we convert it to number, then only we can do plus minus. Otherwise, it will be concatenated in the string. Yes. You are getting the idea, right? You have read DOM manipulation, right? In the previous lecture, I said that these are small things. You must have done Dom manipulation, so you will understand how easy it is to react with Dom manipulation. So what I said, first select this, select this from the query selector, then even listener, click one, then after that, when click on it, then take its text from here, whatever the text was, if it is 0, then it is 0, if it is 1, then convert it to number. Then go and do plus 1 in it. And after doing plus 1, then again change its inner text, then you will see a change in the UI. But you don't have to do this here. How to do it here? Here you can write HTML in javascript. You can write javascript in HTML. You told all this yesterday in basic lecture. I am repeating it again. Understanding basic is very important. Then you can understand advanced things very easily. What are you saying? You understood basic. Then you can understand advanced things easily. So what to do here? I forgot what I had to do, I was telling you that you can write javascript in html, so here you have written zero, you have hardcoded it, so remove this hardcode zero, here you use variable let count is equal to zero, so here we have written let count like this, this is a function, this is a function app, remove the return for a while, This is a function, so here we have written let, we have made a function in this function, we can do anything, but we have also written html in it, so it has become a full JSX, alright, so here we can make a function, we can make a function, the JSX component, see this is a function, we have written html in it, so we are calling it a component, but the normal function where we are not writing html, we call it a normal function. Okay, is it like this? Yes. So here we have to use this variable. So we have to use the java script. How will we do it? So to use the java script, you have to attach curly braces like this. Opened curly braces, closed it. And inside it, if you do like 2 plus 2, then this 2 plus 2 is java script. Yes, so you will get 4 here. Wow. If you remove curly braces, then this is html, so you will get 2 plus 2 only. If you attach curly braces, then java script. So can we put this variable here? can we use this variable here, who said that we can't do it, we can do it, see here, if we change it here, then it will be one, wow, wow, that means now we will put on click here, like if we put it in html, then we will put it on click and change the count, it will be changed I am also thinking something like this. So let's do it, come on. So for this, I will make a function here. I will make a function and put it on click here. Now you know how you used to write on click in html. On click is normal in all small letters. But here it is in your camel case. See, I am getting suggestions because I have set up properly and I have also told you. I did everything in front of you. So you will click on click. See, you are getting the whole thing like this. Now you can call the function in it, whatever function you will make, whatever work you have to do, you can do it here. So what did I do? I said to put on click on it. So will we put it directly in this way? Yes, I told you in HTML that you can use JavaScript in HTML in an inline way. Hmm, you told me this in JavaScript. Yes, we can do this in this too. Okay, we will do this in this. So click on CLIC. I have entered it and it has come here like this. Look again, look again, look again, look again. This is the opening tag. In this, just as the attributes are written here, on click and here So what we have to do is, we have to increment by clicking on increment button. So let's make a function of increment. Name it increment. In increment, we have to do count is equal to count plus one. And put this increment here like this. So when we click, increment will be done. But keep in mind that don't call like this. otherwise it will be infinite call and it will not work. See, is it working or not? Let's reload it again. See, it is not working. By default, we have given 1 in the counter. Keep it 0. See, it is 0. Is it not working? No, it is not working. So, you don't have to do it this way. Here you always have to pass a reference. You can't call like this. We will only pass a reference. When will the call happen? When we click, it will call. When we click, it will call. No, nothing is happening. Nothing is happening because we haven't done CLG yet. Let's see whether it is happening or not by doing CLG. Let's click on increment. Wow, increment is happening. Here increment is happening but it is not happening here. Will I have to go back to the end-to-end manipulation? Select it and then change its init. No, not at all. You can do it very easily. How? using states. So, you understood what we are doing here. In onclick, you have to pass the reference. Look carefully. I made an increment function. You have to pass the reference. You never have to call. Okay. You will get this in many places. In this way. Fat arrow function is used. And you must be working here. So, it's okay. You can also make a direct function here. There is no problem. The function you made here. You make this function here. So, indirectly, you are passing the reference only. Are you calling this function? No. We have made the function, that means indirectly reference is passing here. You do this or make the function outside and pass the reference here. Or pass the whole function like this. No problem, you don't have to call here. You want to say this. Will it work? It is working. But we will not do this. The code will look very dirty. So we will do one thing here. We will leave the increment here and pass the reference like this. But this is the problem, there is no problem at this time, there was a button here, click on increment, make an increment function, the account is being incremented, the basic java script is being incremented, but the update is not happening here. So that's why you don't have to do dom manipulation here, that's why react gives you a use state. I will show you how to use useState. We will see how to use useState in the next video. But for now, I believe you are getting it. I am telling you in a very easy way. So here we have to use useState. What was the problem in normal variable? We are doing change, but change is happening in the variable. UI is not being updated. Then how to react? react you have told in untold story also react means it will react whenever something will change in data according to data ui also it will change react will react react will react but here react is not reacting because you have not used the powers of react now we have to use the powers of react we have to use the state of react so state means data i told you state means data so here let leave let for now Now you have to use useState. You can make a state from useState. You will click on it, enter it and it will be imported automatically. If not, then you have to import it here. And you have to put curly braces here because we are importing named. From where to import? From react. What do you have to import here? UseState. You are also getting suggestions. Rest, most probably, it will be imported here. You have done the proper setup according to me. Here you will enter useState and it will be imported. call it like this. Is it a function? Yes, it is a function. Okay, so call it instead of use. Okay, so what will happen by calling? No, nothing will happen as such right now, but it will be returning an error to you. It will be returning an error. Yes, can we see? You can see. You can't see the rest of the place, but I will show you here that it is returning an error. Okay, the error came because there is no count variable here and we are using count here, we are using count here too. Let's comment for a while. still error is coming increment is not defined let increment be defined we are using count, comment count now it is fine see here we are getting array, why we are getting it twice? I told you go to main.jsx and remove this strict mode it will not be visible twice, you will see it only once reload and see this what we are getting? undefined and a function ok, from where undefined is coming? because we have not given any value in it if we make any variable and don't give any value then what happens? undefined? If you give value like 0, if you give some string here, string is coming, that means the first one is your variable, it looks like a variable, there is some value in it, there is some value in the variable. the other one is function, f means function, so on zero place it looks like a variable and on first index it looks like a function so we will remove both variable and function, so for that we will do destructuring here array is there, so how will we destructure array, for that we will have to make array here to destructure object we have to make object, to destructure array we have to make array, so what will we remove here If we take out the state, then we give the name of the state here, its count variable, you can give any name, the second is your function, then you can give any name of the function, I gave the name of the function, both are the same type of variable, but there is a value in this variable, there is a function in this variable, then is the count a value? Yes, the count is a value, do CLG count, then what is your count? It is a value, very good, now uncomment it, do it, Did we do anything special? No. We just used one state. And we understood this syntax too. Why do we use such syntax? Why did we open and close this bracket? You must have understood this. You must have seen de-structuring. I gave you homework in the previous lecture. Watch the video on de-structuring. I believe it will be 20-25 minutes long. So, here is count and this is function. So, count is variable. If we increment here, it will be concatenated because we have used the string. Now it will work with the number. If we increment here, it will be incremented. But here it is not incremented. You said that when it changes in the state, the react will react. This is because it is not able to track. It will track when you will use the function inside it. You will use this function and change the data. Ok. So here you don't have to change the data in this way. No, you don't have to change the data in this way. You don't have to change the data in this way. So how to do it? You are getting this function here. You have to change the data through this function. Then it will react. Alright. So how will we change the data through this function? So we will put our data inside it. So whenever we will do increment then this function will do 1 to it. Will do 1 to the count value. So let's do increment. Ok, directly changed in UI. Changed in variable. Changed in variable. I will show you. If you will do CLG count. Changed in variable. You can see here also in the function. And here also you can see there is no problem. Changed in variable. Changed here also. That means when something changes in the state then react reacts. All right, it reacts. But not in a normal way, you will do it through this function only. So I give the name of this function as setCount. Why? Because it is updating only the value of this count. So standard practice, good practice, good naming convention is like this. That here you are giving count and here you are giving setCount. From setCount we can understand that this is a function which is made to set the value of this count. And this is your value. So whenever we have to set the value, we will use the set count and here 1. Whenever we click on the increment, it will be 1. But if we click on the increment again, nothing is happening, only 1 is happening. So we will not know. Here we had to do the count value of plus 1. So we can do plus 1. How can we do it? So see here, count is equal to count plus 1 and you put this count here like this. Now see. Wow, wow, look at this, 13, 14, 15, 16, it's fun, it's fun. And if you don't want to do this much, then you can put count plus one here. So what will happen now? See, what was the first time here? The first time was zero. Zero. Will you do increment? Here, click on increment, the increment function will be called, the increment function will be called, then it will call the set count function, it will call the set count function, then the count value was zero first, it will do plus one in zero, then zero plus one will be one. Okay. Now the value of count is 1, not 0. Now the value of count is 1. If you increment again, then count plus 1, that is, how much will be 1 plus 1? 2. Now the value of count is 2, so 2 plus 1 is 3. If it is 3, then 3 plus 1 is 4. Alright, and it is reacting. Whenever something is changing in the data, it is also updating in the UI. Now if I use this UI in multiple places, if I use a count variable like this in multiple places, it will change everywhere. Look carefully. Wow! it interesting? Isn't it interesting? Means the event listener game is no more. We are selecting the event listener and the query selector. If you want to change one element here and there, then select all the places and then work after that. No. Wherever you have used this data, all the places will change. this game is fun, now we understand increment now how to do decrement, we will make similar function here here was increment, here decrement and instead of plus one we will do minus one and in set count value will be minus one and count value will be set and this decrement here on click Decrement is happening. Wow! You have learnt it once. It took some time to learn it. But it was so easy to make another function. You made this, added this and this worked. Listen again. You made this, added this and this worked. Yes, it was fun. Then after that, reset. There is nothing in reset. You have to reset the value to zero. I have told you that you can create a function here as well. There are two ways to create a function. One is called anonymous function. You can also use a name here, but you don't have to call. Then you can create an arrow function in this way. You can also make an arrow function. So it's your choice. If you think you have to make a whole line, then make a function here. Like this way you make a function here and work here. Set count this way. And you can call this. Why? Because you are doing this work inside the function. I have told you that you can put this whole function here. It's not a problem. Right? You don't have to call the function. So the function we have made, we are not calling it. When we click, it will be called. Alright. Or you can make it here and pass the reference. But you will also see this in a lot of places, so I will tell you this too. So what will you do with the set count? Zero. So will your count reset here? See, let's reset, it's zero, wow. Okay. We will increment, it is incrementing, we will reset, it is resetting. Okay. So here this function looks a little long and wide. So here is an easy way that you make a fat arrow function here. How do you make a fat arrow function? This way. This way. Okay, this is a fat arrow function, yes. So here we will count the set. Zero. But if you are not very comfortable now, you want to be comfortable going forward, you are still reading JavaScript, then there is no problem. Here make a separate function of reset. In this way, count the set here. Zero. All right. And pass this reset here. Remove all this. Remove. Here reset. Increment, increment, reload, increment, increment, decrement, decrement, reset, reset, counter application is done. But this is just made. This is just made. Now comes the time to learn. How to break the components. Like here, if the button was styled, then you don't have to worry much here. That the button is styled, so you used the button here. But it is possible that you want to make your own variant of the button, want to make your own component. It is a very stylish button, you are using it in animation etc. So it is a very stylish button and you want that button to be used everywhere in your entire application. So you want us to make that button once and keep it, I am using it everywhere. Suppose you have to give a lot of style in this button, you are using style here, you are using tailwind CSS, you are using a lot of things. So this button component would have become very big. And you don't repeat it like this again and again. Suppose you are giving style here. Now you won't understand how to give style. Suppose you are giving something like this. What am I doing? Flex. Display flex. Flex. Now you don't need to understand this style, it will be separate for this style. Suppose there are many styles, then only one button will be very complicated for you. Do you agree or not? Yes, only one button will be very complicated for you. Then you are replicating that button, then again it will be our HTML. You didn't have to replicate it, right? You made a component once, you are reusing it. You are not repeating it, don't repeat yourself. Reuse it. So you will make a component. How do you make a component? So I told you that this is your component app and you are using that app in main.jsx. Now let's make a separate component. So we have made a component called function button. What will we do? Return. What will come here? A UI will come. Which UI? Let's copy this button one. Now we need only this element so no need to give fragment or div. So this is your button. Now how to use this button? I told you that there is nothing much to use this button. To use this button you have to open the angular bracket like this. You can find this in the suggestions. So you have to use button. and close it like this, self-closing. If we don't do self-closing like in HTML, then we should do this work. Let's remove this onclick, we will get an error here. Where is the increment? You haven't made it. There is no increment in this function. You must know that whatever you are making in this function will remain in this function. We can't use it outside. So let's remove this from here. I believe this error should be removed. The increment button is coming back here. So, we don't do it like this, we do it like this, button and self-closing like this. Okay. Although that is also a way when there is a what do you say child pass, then we will see all that well in the future. So, here we are using the button in this way, we have made this button component, whenever we will replicate this button here, this button will come to us. Now no matter what style you are doing here, whatever style you do here, it will be the same style in all. so it will be easy in debugging too you don't have to change the button everywhere here you will change the style a little and all the buttons will be changed so this is a good thing we will use the button in the same way but the problem is that we are using the button here and suppose we have to use the button three times so let's comment it for the time being so three times increment is coming here we wanted increment once, we wanted title once what we wanted? reload what we wanted? reset, once it was reset, so how will we pass the data, so for that props I told you, ok, I told you everything, but still I am repeating so that you can understand it well, so how will you send the data, so let's say I send the data in the key value pair, let's say I have to send here I will say text. You can give any name here. Give its name as text. Give title. The way you will send, you have to use it in the same way. Just keep in mind. If you are sending by saying title, then you have to use it like a title. If you will say text in this way, then you have to use it like a text. So I will give text as increment. So we have sent text in this button. Will increment be seen here? No, there is nothing like this. You can see increment in everything. You will have to use it. So in this way we can send in component. data and here to receive props or name give object whatever name you give here whatever you will send on the key value, it will be limited to an object and you will get it here, you will send the title, you will get the title, let's say something else here, what can you send and the function will definitely have to be sent, right? The function will also have to be sent, so one will send a funk here, let's say in the funk, let's send something useless here, so here we do CLG object OBJ, see here, What we are getting? Ctrl-Shift-I We are getting an object. Here we are getting a function and a text increment. So, we are getting a key value pair. Here also we are not getting anything. It is empty. Here also we are not getting anything. It is empty. Why? Because we have not sent anything in these two components. We have not sent anything in these two components. It is only sent in these two components. If we send it in these two components too, then you will get it here. See, it came in this too, it came in this too, it came in this too. Alright. If we send a decrement here, decrement. So here you are getting a decrement. Let's reload. See this in the first one increment, in the second one decrement and in the third one. Let's send. What was it? I forget it again and again. Reset. OK. So increment, decrement and reset. Reload again. Increment, decrement, reset. Alright. Now how to use here? So it's a very simple thing. What do you have to use here? Javascript. So to use Javascript, open and close curly braces. Now we have to use this object as a variable. So what are the keys in obj? So obj has a text and a function. So we have to use text. So obj.txt text. Look carefully here. The key should be the same. obj.txt. Okay. So here you see increment, decrement, reset. In the first one, we are sending text increment. So obj.txt is incremented here. In a way, it is a variable. In the second one, we are sending decrement. So here it is decrement. In the third one, we are sending reset. So here it is reset. Ok, so whatever data we will send here, we will be getting all of it in an object. Exactly, we can break that object here and take it like this. If you want, you can also do this structure here. Do this structure in this way. Now here you have to give the same name. Here you can give any name, right? We were using an array, but here the object to destructure the object so while doing that you have to give the exact same name here is text so you have to give text only this is func so here comma func so here you don't need to do obj.text you will just write text here so whatever will be in text variable will be here increment, decrement, rest Now comes the turn of the function, on click, the function that we are getting here, we will pass the function as it is here. The reference of the function that will be coming here, we will pass the function as it is here. So let's send the function quickly. Okay? We will send the increment function here. Now how will we send the increment function? In string format? No, no, we have to send it in java script, right? We have to send java script. So we will put curly braces here. This is the increment. Okay, we have to send decrement here. So decrement in this way. So you can send anything in the data. Then here, which function to send? Reset, see Reset. Ok, so here we have sent increment, here decrement and decrement function, here reset and reset function. So reload here, let's see if it is working, wow, wow, it is still working. Ok, so if you want, do it this way, it was looking easy to you now, but if this function is complex to you, this button is very much styled, we have done a lot of work here. So you don't have to change it again and again, it will change automatically because you have used the same component everywhere. Now you can also make it in another file, how? I will tell you this too, here I have made a new file, for example, I have made a folder named components and in this folder named components, I have made a file called button, write B in capital here. VEET says that you are here, Capital Billy has a naming convention, whatever JSX file you are writing. So our automatic will come from RAFC. Wow, this is also good. And here it is using the fat arrow function. You can also do normal function. So here it was doing normal function. You can also do this. There is no problem. Do this here. Or leave it alone. Put this here. It is your choice. You can use any function here. Okay. So this is our second component in second file. So we don't have to use it from here. We will import it from here. How we will import it? We have export default button here. To import it we will import it here. And because we have default export here, then we can give any name here. Otherwise, we have to give the same name to those who are sending in this way. So here we can give any name because we have done default export. So what name should we give? Let's give the name of the button from where we are importing. So put the dot slash here first and here in the components folder, this is the button. you can understand this relative path and if you don't know then comment that too I will tell you can we use this button here? yes we are using it so there should not be any error no error is coming function is not defined which function is not defined it is telling ok here it is not taking props like this what was coming here? text was coming and function was coming ok So now it is working here. Why does this react come? React is coming but we are not using it. So you can remove it now. You can also do it this way. You can make it by doing react. But we don't do it like this now. So this is simple. This is enough. I will tell you how to do it. We will explore more things in react. So now see this was not highlighted. Means we are not using it now. Remove it. Okay? Okay. So we have made this button component in a different file. So in this file, you can make this button as complex as you want. Just do it as you want, no problem. This is a separate component. Do it as long as you want. There will be no difference in this file. It will work properly here. If you change one place here, changes will be reflected everywhere. Wow! So see how simple the code has become. Remove it and see once. Hmm, it is simple. In this much time, we have made the entire counter app in 35 lines. amazing, amazing and I will leave this also just for your guidance so this is our counter application and I hope you enjoyed it I have explained a lot of things and I believe a lot of things may have been left out which you think should have been explained in detail but it didn't happen so it didn't happen because it was a basic project learning basics was important learning flow was important ok, when I will take you to the depth then you will say that no, leave it We don't even go that far. Okay? We will learn everything. I am telling you, we will definitely learn. And at the same time, I will tell you, next month, next month, yes, next month, after 3rd, after 3rd or 5th, I will bring your interview JSV. Okay. So, till then, react will be going on, interview JSV will come. Interview JSV, not many videos will come. 15 videos, 20 videos, if they are long then 10 videos are enough for interview js. Which interview js? Which one? The same interview js that I told you earlier but I haven't brought it yet. Okay? Those who know or don't know, I will tell you through shots or I will bring the video. I don't prefer video mostly for small roadmaps or to give some information. So to give information, I give all the information in the shots. What is it to make a long video? Okay, if I make a long video, the earning will be good, but I am a little short. And you also like to listen in short, so I make it in short. So, you must have understood the counter application. Here is our counter application. It must have been fun. I hope so. Rest, you tell me. Whatever the feedback will be, you give it honestly. It's not a problem. See you in the next video. Till then, bye bye.