so now that we cant use the hooks as old style of event functions beside disabling the warning what is the best way to call event function that does not violate the rule
import React, { useState } from 'react';
function Example() {
// Declare a new state variable, which we'll call "count"
const [count, setCount] = useState(0);
return (
<div>
<p>You clicked {count} times</p>
<button onClick={() => setCount(count + 1)}> // Lambdas are forbidden in JSX attributes due to their rendering performance impact (jsx-no-lambda)
Click me
</button>
</div>
);
}
const inc = () => setCount(prevCount => prevCount + 1);
and then<Button onClick={inc}>
– Anywise