skip to Main Content

When I created ReactJS project using npx create-react-app <app name> command in Terminal, I got JS files by default came in the react project. I am new to ReactJS and I was asked to develop code in JSX files as per requirement. But I am not sure why doesn’t npx create-react-app <app name> command in Terminal, didn’t create even a single JSX file for me.

Reference:
https://www.jetbrains.com/help/idea/react.html#install_react_in_empty_project

Can you please tell me should i just rename JS to JSX or why the npx create-react-app <app name> command didn’t create even a single JSX file in the React project.

Thank you

2

Answers


  1. When you initialize a project, you have only the files which are like boilerplate code. You can start creating files with .jsx extension and work on your react components.

    Login or Signup to reply.
  2. There is rarely any difference between .js and .jsx files as far as CRA is concerned. create-react-app will create only .js files by default. You have to manually change the file extensions of app.js and index.js to .jsx if you want. Since imports don’t need to include file-extensions in them, you do not have to change anything else. Both the extensions work exactly the same in react.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search