Back this way.
We left by triggering an event to increase our state using the state state.
So what about if you want to decrease the previous state by one?
Well, we are still going to use the set count function to update the state.
So one more time the set can function takes in a callback function, and inside the function we have
access to the previous state, so we take the previous state and add one to it.
So what about decreasing by one?
Here is a clue.
So you create a function or better still, we can do it as even in line.
So let me see one more trick to it.
So let's.
Create a pattern here and say decrease count.
So they're going to do it in line here.
So it's on the button here.
We have the function on click event handler on click and then we pass in the set count function here
to update.
So because we want to call the function and pass in some value, we need to call it as anonymous function
as we did before.
So my normal function here and my arrow function and now I have my set count as a function like that.
So inside this function I'll pass in my callback function like that and then my arrow function is going
to return.
It can be something like this, but because on one line I can quickly.
Because going to retain a single value, I can do it on one line.
So here, instead of doing something like this carry basis and then return something like this one,
the same thing as before.
So here I have access to my previous state.
I would take the previous state minus one.
So let's save it.
And now let's check it out.
If I click on.
Let me refresh it.
Let's increase count and then decrease count.
That is getting increase and now decrease.
So this function can be shortened using the shorthand syntax.
So again, let me go over again.
So let me remove this one from my on click handler here again.
So on click.
Sorry this on click our pass in management function here.
One more time and now I'll call my set count.
And this set count as a function here.
And now in this function, it takes in a callback function as this again.
Then we have access to the PBO states.
And now this function is going to return the previous state.
So we can take the previous state and then subtract one from it.
Because on one line I can quickly return codes, immediately return function.
So I would take my previous state and then minus one.
And which is the same as before.
So if I click on increase and then decrease.
And there we go.
So what about if I want to reset it?
All right.
But what about if you also want to increase by MSY by ten upon upon each click?
How are you going to do it?
So the same as instead of just say plus plus one here we can see that previous states plus ten.
So upon every click they're going to add ten to the previous state.
So increase ten, 20, 30, 40, 15.
And for the decrease to decrease by 100.
So let's see, let's refresh it.
Decrease by 100.
And there we go.
So what about the reset?
All right.
So let's see how we can do the reset in this video or we can even do it right now.
So quickly, let's let's finish up this event handler.
I mean, logic.
So let's create a button here.
We can copy one of this button and they come down here and now let's go this one.
Reset count, reset, count.
And now let's call the function animals here.
And let me guess in my set count, and then I'll pass in zero.
And now whatever I would type here is back to zero.
I can refresh it.
My count -100, I can reset back to zero.
So this is how we handle event in React.
We are going to do more project to put them into practice.
So if I never care with it, don't worry.
I'm going to repeat our set also.