Run Function In React Js using Button

Experienced Full-Stack Developer with a strong background in React.js, MongoDB, Nest.js, and Laravel. Proficient in building scalable applications and RESTful APIs, ensuring optimal performance and scalability. Skilled in implementing responsive design principles and maintaining code integrity through rigorous testing practices. Adept at collaborating with diverse teams to deliver innovative solutions and meeting project deadlines.
// Methods To run function with Button in React JS
export default function Counter() {
const [count,setCount] = useState(0);
function handleIncrement(){
setCount(count +1);
}
return (
<div>
<p>{count}</p>
<button onClick={ _=>{handleIncrement()}}>Increment</button>
<button>Decrement</button>
</div>
);
}
// Other Method
export default function Counter() {
const [count, setCount] = useState(0);
const handleIncrement = () => {
setCount(count + 1);
};
return (
<div>
<p>{count}</p>
<button onClick={ handleIncrement }>Increment</button>
<button>Decrement</button>
</div>
);
}

