import React, {useState} from 'react';
const Counter = () =>{
const [count, setCount] = useState(0);
const onIncrease = () => {
setCount((prev)=> prev+1))
}
const onDecrease = () => {
setCount((prev)=> prev-1))
}
return (
<div>
<h2>{count}</h2>
<button onClick={onIncrease}>+</button>
<button onClick={onDecrease}>-</button>
</div>
)
};
export default Counter;
**
setCount((prev)=> prev+1))