How can this be achieved?
That does not work, the updated counter is not shown.

When clicking the button, the counter is incremented, but no rerender is triggered.
This can be solved through the useState Hook.
Hook functions are called in the render function.
Depending on the Hook, it may have parameters and may provide a return value to access the provided functionality.
Hooks are functions that let you "hook into" React state and lifecycle features.
The Hook function is called in the render function.
Depending on the Hook, it may have parameters and may provide a return value to access the provided functionality.
The eslint-plugin-react-hooks enforces these rules. In the vite setup this is included already
Before Hooks were introduced in 2019, features like state management required the use of class components .
With Hooks these features can be used in function components and thereby makes the code simpler and better reusable .
The array destructuring makes it easy to use multiple states in a component.
The onChange prop takes in a function which is called when the input is changed.
Use event.target.value to access the value which was entered.

Event handlers like onChange receive an instance of SyntheticEvent .
This is a wrapper for the native events , ensuring a consistent API and functionality across browsers.
We learned…