Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Structure of a React Project | React in Practice
Introduction to React
course content

Conteúdo do Curso

Introduction to React

Introduction to React

1. Getting Started: ES6
2. Getting Started: JSX
3. React in Practice
4. React Components
5. Controlling Data & Content
6. Hooks
7. React Router

bookStructure of a React Project

If we look at the project folder, we will find the following files:

The only files of folders that are relevant at this point are:

  • node_modules contains all the installed modules;
  • public contains the main index.html file and other files related to it;
  • src contains a basic template for the HTML page;
  • package.json and package-lock contain data related to the project, the installed modules, and their versions.

We need to start our work by deleting all the files from the src and public folders.

Create an index.html file in the public folder and add the following code:

html

index

css

index

js

index

copy

Create an index.js file and add the following code inside it:

In the index.js file, we import React and ReactDOM to use the React functions.

Note that we don't need to manually import index.js in index.html: it is automatically done for us when we run the application.

We can use the DOM in this script to access the root element from the HTML document and create a root object to render React components. It is done in the second-last line as follows:

In the last line, we use the created React root object to render the Main component, which represents a React component. We will learn more about React components in the next section.

Following is what the output should look like for the above setup:

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 4
some-alt