The useState hook is used to update and display data on the web page. If a component has a value that is changeable , we use the useState hook to handle the change.
useState has a state variable and a function to update that variable.
The state variable holds some data of the component that can be changed.
The function is used to update the variable.
Example: const [count , setCount] = useState(1);
Here count is a variable that holds some data and setCount is a function that will update the variable(count) when needed. 1 is the default value we have given to the count.
Top comments (0)