State is a built-in React object used to contain data that may change over the lifetime of a component. When state changes, the component re-renders.
import { useState } from 'react';
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>
Increment
</button>
</div>
);
}
State characteristics: