React components has a built-in state object . The state object is where you store property values that belongs to the component. When the state object changes, the component re-renders.
Read moreWhere do you keep state React?
Thus to maintain state inside the function, React provides several hooks:
Read more