Kevin Orara
Kevin Orara

Reputation: 187

Is main.js basically the same as index.js?

I have been using the command npx create-react-app my-app to build a new React app environment. It creates a simple and generic app with the React logo. It generates folders such as public with index.html and src with your typical files such as App.css, App.js, and index.js, among others.

While studying the code for reverse engineering purposes I noticed that some projects have a file called main.js. I assume people are manually creating this file and input code similar to pre-populated index.js code (automatically created by npx create-react-app my-app). Essentially code for routing or calling components which gets rendered.

Are these two file names interchangeable or should they serve different purposes?

Upvotes: 2

Views: 6224

Answers (1)

Quentin
Quentin

Reputation: 943578

The file name for the JS file you use as your entry point is arbitrary. Your bundler’s (Webpack, Parcel, etc) configuration will determine which file it looks for.

Upvotes: 2

Related Questions