Interpretation of the official blog: react18 is really coming

Time:2021-10-19

At 1 a.m. on the 9th,ReactOfficial blog releasev18Latest progress.

Interpretation of the official blog: react18 is really coming

Three official messages

In the blog post of react18 work plan, the official brought three messages.

  1. v18Work is already in progress and will be the next major release
  2. Createdv18Working group, let community experts, developers and library authors try it firstv18It is pre compatible with many libraries in the communityCM(concurrent mode), education and community preparation

Interpretation of the official blog: react18 is really coming

Workgroup address

  1. Releasedv18 AlphaVersion so that library authors can try and provide feedback

Use v18 alpha

Next, let’s interpret the information behind the message.

What is the stepping stone

We know,v17yesStepping stoneVersion to stabilizeCM

CMThe reason why it is difficult to stabilize is summarized in one sentence:

CMbyReactBring application levelBreaking Change, and unprecedented

The workload here includes two parts:

  • For supportv18Development costs for new features
  • Help the community gradually upgrade tov18Development and communication costs paid

Development cost of new features

v18Main characteristics ofStreaming SSRPre dependencySuspend with different priorities

Suspend with different prioritiesPre dependencyMore flexible cm

Flexibility here refers topriorityNot only can they be compared separately, but alsobatchThe concepts are compared with each other.

thereforeAndrewstayv16.13.1It needs to be completed firstlanesDevelopment of priority scheduling algorithm.

At the same time, the underlying supportMore flexible cmAfter, it also brought to the upper layer, such as:

  • startTransitionuseDeferredValueIn this wayAPI, allows developers to explicitly specifyUIPriority of rendering.

For example: can useuseDeferredValue, according to the user equipment performance (QPS), automaticdebounceFunction.

  • newAPIFor exampleOffScreen(it can be understood asReactEditionkeep-alive
  • automaticbatchUpdate, not limited to event callback functions

Cost of progressive community upgrading

The official also revealed in the latest progress that it was upgraded tov18There will be no, or very few changes to existing code.

as a result of:CMIs optional (i.eTime sliceIs off by default).

Just now,CMPre dependencyPriority scheduling, andPriority schedulingYesTime sliceImplemented on this architecture.

So, whenTime sliceAfter being closed by default, the existing code can be smoothly upgraded tov18

Interpretation of the official blog: react18 is really coming

As you can see,Time sliceThe property is marked asUmbrella, it means that this feature will affect a lotAPI, architecture, library

stayv17At the time of publication,ReactInternal refactoringEvent mechanism

ReactEvents do not bubble to the unified root node, but to each application (i.e. call)ReactDOM.renderThe root node of the.

Interpretation of the official blog: react18 is really coming

This allows a portion of the entire application to remain currentlegacyMode, new part enabledCM, because these two sub applications are independent of each other.

becauseCMBringBreaking ChangeMake a large ticket library incompatible (e.gmobx), soReactNew technologies have also been developedAPI —— create-subscriptionUsed to subscribe to external dependencies.

That’s whyv18 AlphaPriority will be given to library authors – the existing implementation of the library is openCMWhen fully functional, it may be incompatible.

point of time

currentv18 AlphaAlready available. OpenbetaThe version will be released in a few months.

staybetaA few weeks after the release, it will be releasedRCedition.

Finally, inRCThe stable version will be released at least a few weeks after the release.

Therefore, the overall forecast is:v18The stable version will come at the end of the year.

At that time,ReactThe team will focus onServer ComponentsCome on.

Interpretation of the official blog: react18 is really coming

ReactHow to upgrade and the most efficient way to upgrade the react source code