react learning - State Hook

1, State Hook 1,useState State Hook is a function used in function components (useState), which is used to use state in function components useState The function has a parameter whose value represents the default value of the stateThe return value of the function is an array, which must contain two items Item 1: value of current stat ...

Posted by hairyjim on Thu, 10 Feb 2022 13:41:47 +0100

Get started with React routing quickly without nonsense

This article aims to be concise and help you get started quickly. By default, you have been exposed to routing related development install Enter the following command to install: // npm npm install react-router-dom // yarn yarn add react-router-dom React router related labels There are eight common components of react Router: import { ...

Posted by xtiano77 on Thu, 10 Feb 2022 06:04:03 +0100

Using craco to optimize the construction of cra project

Modify the configuration of CRA project A project created with create react app cannot modify its internal webpack configuration by default. Unlike Vue cli, it can be modified through a configuration file. Although an eject command can completely expose the configuration, it is an irreversible operation and will lose the convenien ...

Posted by ajcrm125 on Wed, 09 Feb 2022 16:49:55 +0100

React source code analysis - API series - react createRef/forwardRef

preface In this article, we will continue to analyze the two APIs of createRef() and forwardRef() in react. First, we will talk about the concept of ref and how it is used in react, and then analyze the source code implementation of these two methods in react. text First, let's take a look at the basic usage and some concepts of ref in r ...

Posted by c4onastick on Mon, 07 Feb 2022 13:54:15 +0100

♣ Use of React Hooks

Use of React Hooks Why do I need a Hook? Hook is a new feature of React 16.8 that allows us to use state and other React features (such as lifecycle) without writing class es. The class component can define its own state, which is used to store the state within the component itself. Functional components are not possible because each call to a ...

Posted by jaku78 on Fri, 04 Feb 2022 19:07:23 +0100

React technology disclosure learning

study Uncover the secrets of React Technology Render phase - Coordinator - Reconciler work Start at the workflow.syncformoncorrent phase Depends on whether the update is synchronous or asynchronous // performSyncWorkOnRoot calls this method function workLoopSync() { while (workInProgress !== null) { performUnitOfWork(workInProgress); ...

Posted by mosherben on Thu, 03 Feb 2022 14:50:03 +0100

Failure investigation and replacement scheme of scrollIntoView

Problem background Today, we need to do a function of clicking icon to slide to the article comment area, using scrollIntoView. It is found that the mobile terminal occasionally fails. The code is as follows: commentRef.current.scrollIntoView({ behavior: 'smooth', }); analysis Think about whether 1 is caused by a browser bug accor ...

Posted by Formula on Thu, 03 Feb 2022 10:27:10 +0100

♠ Use of redux and react redux

Use of redux JavaScript pure function In functional programming, there is a concept called pure function. JavaScript conforms to the paradigm of functional programming, so there is also the concept of pure function; Wikipedia definition of pure functions:   In programming, a function is called a pure function if it meets the following condition ...

Posted by wizzard on Thu, 03 Feb 2022 10:08:12 +0100

Take you hand-in-hand for 10 minutes to create a simple Markdown editor

preface Recently, I need to implement the requirement of a markdown editor in my project, which is developed based on the React framework, similar to Nuggets: My first thought is that if you can use excellent open source, you must use open source. After all, you can't always build wheels repeatedly. So I asked a lot of friends in my front-e ...

Posted by playaz on Thu, 03 Feb 2022 02:41:57 +0100

Take you hand in hand to build a simple webpack scaffold

Plugin plug in In the whole process of webpack, loader enables webpack to process more file resources. The plugin exists in the whole packaging process of webpack. The processed content can be processed when the hook exposed by the webpack is triggered. So we can use plugin to process the files in process. index.html file processing Before, ...

Posted by andremta on Thu, 03 Feb 2022 02:15:05 +0100