I have a piece of code as below:
for (let i = 0; i <= total; i++)
leftButtons.push(<Button onClick={() => console.log(i)} key={`leftBtn_${i}`} color="primary">{i + 1}</Button>);
This will cause a compiling error and the error message as "Module parse failed: Unexpected token (36:23) You may need an appropriate loader to handle this file type."
If I remove console.log(i) or change it to do not use i in the onClick, it will pass the compile. I really confuse why I can not use i in the onClick.