I feel like this may be a babel problem. I decided to move package.json, webpack.config.js and .babelrc to the top level due to a recommended approach on a guide I was following. Was hoping to get a second look at eyes with how I’ve configured my React. Thank you for all the help.
Most likely a Babel problem indeed, as it seems it’s not transpiling JSX to JS.
The Babel configuration is always giving me headaches, and right now I am not really sure, but isn’t babel.config.js supposed to replace .babelrc? If I am right about that, your babel.config.js will take precedence, and it does not include necessary presets like @babel/preset-react. That might be what causes JSX not to be transpiled.
Hm I’ve been trying to look into babel.config.js and it doesn’t seem to be a requirement. I may be wrong but thank you for replying. Will continue to look about both files.
Thank you for replying. Actually, it isn’t my first time using React but every time I try to use it for a project, the initial setup is usually a headache when it comes to webpack. Thank you for providing those linkes. I will take a look especially the tutorial I hope will point me in the right direction. As for the packages I installed, it’s
What happens if you add the "@babel/preset-env" and "@babel/preset-react" presets to the babel.config.js, and remove .babelrc entirely?
It really looks to me like "@babel/preset-react" is just not applied, and you definitely do not need both a babel.config.js and a root .babelrc, so you can simplify your setup by only using the former.
I thought it was because the react component isn’t immediately closed and all the docs seem to wrap those in parens on the react website. Plus, I’ve been bitten by many weird syntax errors while mixing jsx and plain Javascript so I thought it was worth a try. But admittedly, I still don’t have a clear mental model about the jsx syntactic rules (even after having shipped a product that relies a lot on react and has the same configuration as op, yet somehow works).
You were 100% correct in this one. I didn’t remove .babelrc but made the file and copied what was added in @kokolegorille and it started to work. From what I found in the docs, it looks like babel is trying to look for babel.config.js file which is what was causing this problem.
In my opinion React is cool but weird. The reason being when you use syntactic sugar (I forgot which package helps with it) there is a lot of crazy things you can do. Technically we are writing it in a style but it’s being translated into something different. An example was when I had to bind every function I was making before but now just needing to name = () => {}