useState is a React hook that allows you to add state to functional components. In this example, value
is the state variable, and setValue
is the function used to update it.
const [value, setValue] = useState(0); <button onClick={() => setValue(value + 1)}> Click me </button>
Try clicking the button to see the value
update!