How to use useEffect and setInterval correctly

background useEffect seems simple, but it's not. Because I didn't understand the working principle of useEffect, I was severely cheated. The thing is this: I want to achieve a very simple "object falling" effect: The vertical position of the object is represented by the state of position y. calculated from top to bottom, the la ...

Posted by ganesan on Wed, 02 Feb 2022 22:22:03 +0100

React learning notes

Three properties of component instances 1. Attribute I state [concept] React regards components as a state machine. Through the interaction with users, different states are realized, and then the UI is rendered to keep the user interface and data consistent. [note] this in the render method of the component is the component instance obje ...

Posted by introvert on Wed, 02 Feb 2022 21:38:48 +0100

React router: build multi page SPA

Using Router, you can build a multi page single page app 1. Install the react router: npm intall react-router-dom 2 basic usage 2.1 App.js import Route component import { Route } from "react-router-dom"; 2.2 App.js definition path: There are two paths: http://localhost:3000/welcome http://localhost:3000/products Load correspo ...

Posted by avalonindigo on Wed, 02 Feb 2022 21:17:25 +0100

Basic knowledge of react

Basic knowledge: ReactDOM.render to render elements. There are generally three parameters: the rendered content of the template (in HTML form), the DOM node to be inserted, and the callback after rendering (generally not used) react CreateElement create tag (virtual DOM simulates real DOM, compares the difference, and then renders) 2. By intro ...

Posted by dalecosp on Wed, 02 Feb 2022 07:02:50 +0100

React high level guidance: Context context & component combination & Render Props

React high level guidance: Context context & component combination & render props preface Today is also to explain the advanced application skills of React. The content may involve the use of some special API s, or the special usage of React components and props. It can be regarded as a design pattern, an exclusive design pattern ...

Posted by stennchau on Tue, 01 Feb 2022 22:24:31 +0100

Use a more readable way to set TypeScript types

Author: SARANSH KATARIA Translator: front end Xiaozhi Source: wisdomgeek There are dreams and dry goods. Wechat search [Daqian world] pays attention to this dish washing wisdom who is still washing dishes in the early morning. This article GitHub https://github.com/qq449245884/xiaozhi It has been included. There are complete test sites, ...

Posted by zarp on Tue, 01 Feb 2022 21:17:54 +0100

[actual combat of the project, complete source code] teach you how to package components, rewrite React and learn online III

After reading this tutorial, you can learn the following knowledge points: Split components according to business requirements Knowledge of reusable components How child components receive data from parent components - in the last issue, we learned how to transfer data from parent components to child components Can use useState hoo ...

Posted by koolaid on Mon, 31 Jan 2022 22:09:36 +0100

React advanced -- Hook learning notes

1. Hook introduction Hook is a new feature added in React 16.8.0. You can use state and other React features in function components. ✌️ Hook usage rules: Hook s are JavaScript functions, but there are two additional rules for using them: Hook can only be called on the outermost layer of a function. Do not call in loops, conditional judgemen ...

Posted by JStefan on Mon, 31 Jan 2022 14:51:08 +0100

Unit test React components

A characteristic of front-end development is that it will involve more user interfaces. When the development scale reaches a certain degree, it is almost doomed that its complexity will increase exponentially. Whether in the initial construction of the code or in the subsequent unavoidable reconstruction and bug correction process, it is often ...

Posted by dnzone on Mon, 31 Jan 2022 05:22:00 +0100

[React] < JavaScript framework > Event Processing & high-order function & function coritization

catalogue 1, Event handling: 2, Collect form data: 1. Controlled components: 2. Uncontrolled components: 3, Higher order function & coritization of function: 1. Function coritization: Overview of coritization: Application of coritization:  2. No coritization: 1, Event handling: Specify the event handler function through t ...

Posted by Stickdragon on Sun, 30 Jan 2022 15:03:49 +0100