I have a button that runs an onClick function as follows:

 Generate
 

const handler= () => {
 let generator = new PasswordGenerator()
 setPassword(generator.generatePassword(strengthOption, numbersOption, symbolsOption))
 }

Why can't I just do  instead? Currently I'm using an arrow function that executes the same generatePassword()? Why does it have to be an arrow function for the onClick button?
user
{"source": "ewof/sharegpt-instruct-unfiltered-deduped", "kind": "human", "evolved_from": null}
I have a button that runs an onClick function as follows:

 Generate
 

const handler= () => {
 let generator = new PasswordGenerator()
 setPassword(generator.generatePassword(strengthOption, numbersOption, symbolsOption))
 }

Why can't I just do  instead? Currently I'm using an arrow function that executes the same generatePassword()? Why does it have to be an arrow function for the onClick button?
user
DUMMY RESPONSE
assistant