I've noticed that sometimes react doesn't execute an onClick reference & we'll have to wrap it in another function that executes it. What are the cases/ reasons for this behaviour
Eg:
export const DemoComponent = () => {
const sayHello = () => console.log('Hello');
return (
<>
<button onClick={sayHello}>This will work</button>
{/* Why does the below not work? */}
<button onClick={window.location.reload}>This will not work</button>
<button onClick={() => window.location.reload()}>This will work</button>
</>
);
};