Say I have a simple React stateless component like so:
const myComponent = () => {
const doStuff = () => {
let number = 4;
return doubleNumber(number);
};
const doubleNumber = number => {
return number * 2;
};
return <div>Hello {doStuff()}</div>;
};
export default myComponent;
Based on the eslint error I receive, and my understanding of how 'const' works, I assumed that this component would not render, since the function 'doubleNumber()' is used by the function 'doStuff()' before it is initialized. However, whenever I use this component, it renders as expected - why doesn't it throw an exception? Does this mean the order of 'const' variables in React components can be whatever we like?