I had a javaScript function with many nested functions. First I declared all my functions like function funcName() {...js code} and everything was fine. Then I've created a React app that uses ES6 syntax, such as arrow functions. Now I'm trying to import my well tested javaScript function to the React app. I changed all that nested functions to arrow functions with the same content to keep using ES6 syntax. Now when any of that functions is called, I get an error: 'Cannot access 'circlesByPath' before initialization'. This one is for circlesByPath func, when I change it back to normal function syntax, I don't get this error. Can anyone answer why is this happening? I previously considered arrow functions to be only a modern way to declare function, I didn't use arrow functions in vanilla javascript, only in my React app. Now I see something is wrong with them...
I returned function keyword to every function. Now The problem is "ReferenceError: holesNum is not defined" It happens every time when script uses variable that was meant to be global (declared with no 'var', 'let' or 'const' keywords), it worked before (without React), now all variables are undefined...