I started learning React and now I'm trying to understand what is the purpose of the index.js
and App.js
which are created by by running create-react-app.
Why can't we just use, for example. App.js
?
I've read that App.js usually used as a main entry point to the application, but auto-generated code of index.js
seems like a part of main entry point:
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();
I saw a similar questions for react native but I want to know about this in react in general.