When I have a react hook and inside of it I want to define a function in it, would I better use
useEffect(() => {
//...
function handler() {}
//...
}, []);
or the newer const declaration
useEffect(() => {
//...
const handler = () => {}
//...
}, []);
Are both exactly equivalent or are there differences in how Javascript handles these things?
If I define a const, it's only valid within the current scope, while defining a function would be valid elsewhere, is this true?
Does react need the functions accessible in different scopes or are they staying local in the current hook scope?