My question is what does it change to declare a constant above or bellow a React functional component (or a class component also) ? for example what is the difference if I do :
const myName = "Olivier";
const myReactComponent = () => {
const whatsMyName = (name) => console.log(name);
whatsMyName(myName);
return(<div></div>);
}
OR
const myReactComponent = () => {
const myName = "Olivier";
const whatsMyName = (name) => console.log(name);
whatsMyName(myName);
return(<div></div>);
}
If someone could explain to me the difference It would be great ! Also for example Could I move the whatsMyName function above also ? My guess is that it has to do with react Life Cycles . Thanks so much !