useState

Pascual Vila
Frontend Instructor.
useState is a hook that allows you to add local state to functional components. Each time the state changes, the component re-renders.
Example of useState:
{`import React, { useState } from "react";
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<h1>Counter: {count}</h1>
<button onClick={() => setCount(count + 1)}>Increment</button>
</div>
);
}
export default Counter;`}