ReactJS-.JS vs .JSX

Something really confuses me when I work at React.

There are many examples of using files .json the Internet, .jsxbut many others use files .jsx.

I read about files .jsxand I understand that they just let you write HTML tags in yours javascript. But the same thing can be written to files .js.

So what is the difference between these two extensions .jsand .jsx?

+108
source share
5 answers

No file extensions. Your transmitter / transporter / no matter how you decide what type of file content is.

, .js .jsx. JSX JavaScript, , , "" JavaScript, , .. .jsx JSX .ts TypeScript .

+86

/, JSX, JS! , JS JSX.

- javascript, JSX JS. Theyre !

/ JSX JS - , JS .

+18

JSX- (<Component/>) javascript , <script>, . , React, , JSX, JS.

, React .js .jsx, React. .jsx. JSX .jsx.

, , , , JSX.

: .

+14

, JSX javascript, .jsx, - , , HTML-, , ul> li

<ul>
  <li></li>
</ul>
+1

JSX JavaScript, Airbnb 'eslint'

    // filename: MyComponent.js
function MyComponent() {
  return <div />;
}

as a warning, if you named your file MyComponent.jsx, it will go away, unless you edit the eslint rule, you can check the style guide here

0
source

Source: https://habr.com/ru/post/1685505/


All Articles