Home Web Front-end JS Tutorial What to learn before learning react.js

What to learn before learning react.js

May 18, 2019 pm 02:25 PM
react.js

You must learn the basics of JavaScript before learning reactjs, because React is a JavaScript library used to build user interfaces, most of which are JavaScript ES6 and its features and syntax, including ternary operators and simplified syntax. , this object, JavaScript built-in functions, etc.

What to learn before learning react.js

#In the process of introducing React to others, I came to the conclusion that React is all about JavaScript. Also, there is a lot of material about JavaScript rather than React.

Most of this is JavaScript ES6 and its features and syntax, but also includes the ternary operator, simplified syntax, the this object, JavaScript built-in functions (map, reduce, filter) or more general concepts such as Composition, reusability, immutability, or higher-order functions. You may not need to master these basics before getting started with React, but you will definitely need to use them during learning or practice.

React and JavaScript classes

For React class components, prior knowledge of JavaScript classes is required. The concept of JavaScript classes is relatively new. Previously, only JavaScript's prototype chain could be used to implement inheritance. JavaScript classes are based on prototypal inheritance, making the inheritance system simpler.

One way to define React components is to use JavaScript classes.

class Developer {
 constructor(firstname, lastname) {
   this.firstname = firstname;
   this.lastname = lastname;
 }
 getName() {
   return this.firstname + ' ' + this.lastname;
 }
}
var me = new Developer('Robin', 'Wieruch');
console.log(me.getName());
Copy after login

A class describes an entity and is used to create instances of the entity. When you create an instance of a class using the new statement, the class's constructor is called. Properties of a class are usually located in the constructor. In addition, class methods (such as getName()) are used to read (or write) the instance's data. Instances of a class are represented within the class using the this object, but externally, they are only assigned to JavaScript variables.

In object-oriented programming, classes are usually used to implement inheritance. In JavaScript too, the extends statement can be used to make one class inherit from another. A subclass inherits all the functions of a parent class through the extends statement, and can also add its own functions.

class Developer {
 constructor(firstname, lastname) {
   this.firstname = firstname;
   this.lastname = lastname;
 }
 getName() {
   return this.firstname + ' ' + this.lastname;
 }
}
class ReactDeveloper extends Developer {
 getJob() {
   return 'React Developer';
 }
}
var me = new ReactDeveloper('Robin', 'Wieruch');
console.log(me.getName());
console.log(me.getJob());
Copy after login

The above is the detailed content of What to learn before learning react.js. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to call the method of child component in React parent component How to call the method of child component in React parent component Dec 27, 2022 pm 07:01 PM

Calling method: 1. Calls in class components can be implemented by using React.createRef(), functional declaration of ref or props custom onRef attribute; 2. Calls in function components and Hook components can be implemented by using useImperativeHandle or forwardRef to throw a child Component ref is implemented.

How to debug React source code? Introduction to debugging methods using multiple tools How to debug React source code? Introduction to debugging methods using multiple tools Mar 31, 2023 pm 06:54 PM

How to debug React source code? The following article will talk about how to debug React source code under various tools, and introduce how to debug the real source code of React in contributors, create-react-app, and vite projects. I hope it will be helpful to everyone!

In-depth understanding of React's custom Hooks In-depth understanding of React's custom Hooks Apr 20, 2023 pm 06:22 PM

React custom Hooks are a way to encapsulate component logic in reusable functions. They provide a way to reuse state logic without writing classes. This article will introduce in detail how to customize encapsulation hooks.

Why React doesn't use Vite as the first choice for building apps Why React doesn't use Vite as the first choice for building apps Feb 03, 2023 pm 06:41 PM

Why doesn’t React use Vite as the first choice for building applications? The following article will talk to you about the reasons why React does not recommend Vite as the default recommendation. I hope it will be helpful to everyone!

How to set div height in react How to set div height in react Jan 06, 2023 am 10:19 AM

How to set the div height in react: 1. Implement the div height through CSS; 2. Declare an object C in the state and store the style of the change button in the object, then get A and reset the "marginTop" in C. That is Can.

7 great and practical React component libraries (shared under pressure) 7 great and practical React component libraries (shared under pressure) Nov 04, 2022 pm 08:00 PM

This article will share with you 7 great and practical React component libraries that are often used in daily development. Come and collect them and try them out!

10 practical tips for writing cleaner React code 10 practical tips for writing cleaner React code Jan 03, 2023 pm 08:18 PM

This article will share with you 10 practical tips for writing simpler React code. I hope it will be helpful to you!

[Translation] Refactoring React components using custom hooks [Translation] Refactoring React components using custom hooks Jan 17, 2023 pm 08:13 PM

I often hear people talk about React function components, mentioning that function components will inevitably become larger and more logically complex. After all, we wrote the component in "a function", so you have to accept that the component will expand and the function will continue to expand.

See all articles