Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Introduction to Components | React Components
Introduction to React
course content

Course Content

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

bookIntroduction to Components

In the previous section, we looked at how we can create complex elements using JSX. However, React has components that we can do the same, and more, in a neater manner.

React components are reusable blocks of code that render parts of the user interface. They allow for a top-down data flow, as data can be passed down to nested components. Components can also hold a state, which triggers re-renders upon data changes. Components are defined using JavaScript and JSX syntax, which promotes modularity and code reuse, making it easier to create complex user interfaces.

Following is an example of a simple component-based application:

Note: Drag the slider from the left to access the code.

carousel-imgcarousel-imgcarousel-img

You don't need to understand all the code, as everything will be explained in the later sections. However, taking a brief look and getting more acquainted with the program's structure will help.

In React, there are two types of components: class components and functional components.

Class components are also known as stateful components because they can hold a state, which allows the component to update based on changes in data. Previously, functional components were referred to as stateless components, but with the introduction of Hooks (which we will cover later), functional components can now also hold a state.

The distinction between functional and class components is now primarily a syntactical difference thanks to the more recent updates, so it's not necessary to learn both. In this course, we will focus on functional components since they are simpler, and the React community recommends using them.

Select all the qualities of a React component:

Select all the qualities of a React component:

Select a few correct answers

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 4. Chapter 1
some-alt