Sorry if this is a stupid question, I'm new to JavaScript and React. UseCallback is needed to wrap a callback function to avoid recreating the function because it is defined in a functional component which is re-run each time it's state changes. Why don't we just define the callback outside of the functional component to avoid this problem?
// define handleClick here instead?
// const handleClick ...
function MyComponent() {
// handleClick is re-created on each render
const handleClick = () => { console.log('Clicked!'); };
}