Why does create-react-app creates both App.js and index.js?

后端 未结 2 1595
一向
一向 2021-02-02 08:26

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-

2条回答
  •  难免孤独
    2021-02-02 08:59

    index.js is the traditional and actual entry point for all node apps. Here in react it just has code of what to render and where to render.

    App.js on the other hand has the root component of the react app because every view and component are handled with hierarchy in React, where is the top most component in hierarchy. This gives you feel that you maintain hierarchy in your code starting from App.js.

    Other than that, you can have the App logic in index.js file itself. But it's something related to conventions followed by the community using the library or framework. It's always feel good to go along the community.

提交回复
热议问题