Js vs Jsx react

When to use index.js and when index.jsx sa I see in some repos people use .js instead .jsx ?


There is absolutely no difference. It’s all up to your personal preference.

But for what .jsx format was created? If u can use similar code in .js

.jsx format lets you just write html tags in your functions and those will be converted automatically by babel into react dom commands.

No the .js extension does the same. The history here is that the jsx extension used to be the only way to use react, but in the last few months most people have started transpiling their .js files to support that syntax. Meteor 1.3 is the first version that supports JSX syntax in .js files, so all examples older than that will use the .jsx extension.

In the wider react community I think using the .js extension is the norm.

1 Like

I wasn’t aware that 1.3 changed that! Good to know!