React test app
Transcript
English (Auto-generated)
you can see that we have this interpret text in our application and we can think this milieu also. Right? But now this is not enough and we want to control this form element type, we want to get its value whenever we right, anything inside this input text, we want to use it. Maybe do some epoch all with that input or anything. So to do that thing in the act we are going to use react hooks and we are going to use you state as our hook. Let me import that. Use state. You're going to import it from the library Look and we're gonna use it here. So this you state function. New state hook will give us two things. It will give us ah ready, you will which will bind the form element. You can name them whatever you want. And second is a function which we will use to set our state Hey now let's bind our input that with this variable. I'm gonna save it. And let's see you can see that we have find this very well they were input elements and if you give if you want to give any default value to our farm elements, you can just give it here. Right. And let's say I like hello and now you can see that I have this value defined here. Hello world, but I can't change it now and it is important to give some initial value in our case we will give it an empty string. And now you can also see that we can't type anything here. So to make it work in the act we have to bind on change function inputs that and we create our that's some function here. If you're gonna create this now in this custom function it will set the value of our state here which is going to bind which we have already bind with input elements. So as soon as we're going to change anything in our input it will run this function in this inside this function we set the value and the value of state gets updated and we get the updated state in our input type. So let's set the value of our state set will use even brought targets not value that's favorite. Refresh it. Oh you can see I can type anything I want and whenever I have to get a value of this farm type I usually Get this state value and I'll get the updated one. Thank you.