Hooks:-
What is hooks :- hooks is a special function that is used in the function component for handling state , api call , async promises handling and all this feature which you handle in the class component only now using hooks we can handle all this feature.
When would I use a hook? : if you write a function component and you realize you need to add some state to it , previously you need to convert it into a class component but with the help of hooks you can easily handle state in the function component.
Example:- useState is a hook that use to add the state in function component
Here is an example of how the hooks are working
Output:-
In this above example you can click the button and change the count
0 Comments