Rohit
Rohit

Reputation: 450

Which file is more suggestable to use jsx or js file in react application and why?

In React, there is two ways to use the react file. one is JSX and another is js file. my doubt is why react created new extension to develop the react application event though js file format is getting support by it.

Upvotes: 1

Views: 1717

Answers (1)

Curro González
Curro González

Reputation: 31

You can use js extensions for JSX components if you want. But actually JSX is not JS standard. I think thats why they created a new extension. Being strict, JSX is not JS.

Some eslint rules, like airbnt ruleset, force to you to use .jsx extension for React components, and .js extensions for JS 'plain' code.

Here there is a interesing thread discussing about that:

https://github.com/airbnb/javascript/pull/985

Upvotes: 1

Related Questions