Front-end interview skills collection Part 14: High-frequency test points (React common test basic knowledge points)

This is a record 前端面试的话术集锦第十四篇博文——高频考点(React常考基础知识点)and I will keep updating this blog post. ❗❗❗

1. Life cycle


V16Mechanism introduced in version Fiber. This mechanism affects some life cycle calls to a certain extent, and also introduces new 2ones APIto solve problems.

In previous versions, if you had a very complex composite component and then changed the top-level component state, the call stack could be very long.

If the call stack is too long, coupled with complex operations in the middle, it may cause the main thread to be blocked for a long time, resulting in a bad user experience. This Fiberproblem was created to solve this problem.

FiberIt is essentially a virtual stack frame. The new scheduler will freely schedule these frames according to priority, thus changing the previous synchronous rendering to asynchronous rendering, and calculating updates in segments without affecting the experience.

ReactThere is its own set of logic for how to distinguish priorities . For animations that are very real-time, that is, if 16 msthey must be rendered once to ensure that there is no lag, the update Reactwill 16 ms(以内)be paused every time and returned to continue rendering the animation.

For asynchronous rendering, there are now two stages of rendering: reconciliationand commit. The former process can be interrupted, while the latter cannot be paused and the interface will be updated until it is completed.

1.1 Reconciliation stage

  • componen

Guess you like

Origin blog.csdn.net/lvoelife/article/details/132737284