Js vs Jsx react


#1

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


#2

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


#3

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


#4

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


#5

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.


#6

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