Hello, in this tutorial, we'll go over the project/file structure of a React application.
Hello, in this tutorial, we'll go over the project/file structure of a React application.
The package.json File
The package.json file is a configuration file commonly found in Node.js projects. Since we used Node.js and the npx create-react-app command from npm to create our React project, it created one for us.
The purpose of it is to:
You can also use it to define scripts. When we ran npm run start, it is executing the command call "start" in the scripts property.
The package.json file also contains other information such as the name of the project, the version, and other metadata that may be important to your project.
The public Folder
In the project, you can find a folder call public.
To demonstrate this, when you launched the React application using npm run start, you can get display logo192.png by doing:
The src Folder
There is another important folder that you should know about. That is the src folder.
One file in particular if you are new to React, is index.js. That is the starting point of the app besides the index.html file in the public folder.
If you look inside the index.html file, you can see a div element with id="root".
When the React app launches, it'll load the index.html page, and the index.js file will be executed.
In the above code snippet, <App /> is a component that is generated when we created the React application using a command. That is also located in the src folder.
The node_modules Folder
The node_modules folder is also something that comes when we create a project with Node.js. It is used to store all the installed dependencies and the project will know to look into it to find what it needs.