Hello everyone, I am Carson.
Thinking back to the past few years, no matter whether it is React
or not Vue
, they are rapidly iterating versions, so that many students complain that they can't learn anymore .
And now, React
it has not been updated and stable for a year release
.
Some people even think that this is the most direct evidence that the front end is dead :
So, React
why hasn't it been published in the past year? Is it because there is no new work to do in the field of front-end frameworks? React v19
Is it too far away?
Welcome to watch the circle of friends, join the high-quality front-end communication group of human beings , and take the lead
Has React been active in the past year?
For students who don’t want to read long articles, here is a sentence to summarize the point of view of this article:
React
The reason why the version has not been released for a year is not because there is no work to do, but to completeUI
the transformation of the framework from library to meta-framework
First of all, let's take a look, React
has the update activity decreased in the past year?
From push
the perspective of the amount of code, the last year is even release
more active than the previous years with more output:
Now that you are more active, React
what exactly are you doing during this time? You can get a glimpse of the clues from the number of lines added or deleted in the code , where:
-
The green column represents the increase in the number of lines of code
-
The red column represents the reduction of the number of lines of code
-
The red broken line represents the overall trend of the number of lines of code
From the perspective of code volume changes , React
history can be roughly divided into four periods:
-
13 years of open source, to the functional iteration period before 17 years
-
Refactoring period lasting until 18 years (refactoring
React Fiber
architecture) -
18~22年基于
Fiber
架构的新功能迭代期 -
22年至今的重构期
功能迭代期与重构期的区别在于:
-
前者主要是在稳定的架构上迭代新特性
-
后者一般重构底层架构的同时,重构老特性
剧烈的代码量波动通常发生在重构期。比如,在最近的重构期内,PR #25774删除了3w行代码。
这个
PR
主要改变React
对于同一个子包,同时拥有.new
、.old
两个文件的开发模式
最近一年React都在干啥?
明确了React
最近一年处于重构期。那么,究竟是重构什么呢?
答案是 —— 将RSC
(React Server Component
,服务端组件)接入当前React
体系内。
有同学会问:RSC
只是个类似SSR
的特性,为什么要实现他还涉及重构?
这是因为RSC
不仅是一个特性,更是React
未来主要的发展方向,其意义不亚于Hooks
。所以,围绕RSC
的迭代涉及大量代码的重构。比如:
-
SSR
相关代码需要修改 -
SSR
代码修改导致Suspense
组件代码修改 -
Suspense
的修改又牵扯到useEffect
回调触发时机的变化
可以说是牵一发而动全身了。
RSC为什么重要
为什么RSC
对React
这么重要?要回答这个问题,得从开源项目的发展聊起。
开源项目要想获得成功,一定需要满足目标用户(开发者)的需求。
早期,React
作为前端框架,满足了UI
开发的需求。在此期间,React
团队的迭代方向主要是:
-
摸索更清晰的开发范式(发布了
Error Boundray
、Suspense
、Hooks
) -
修补代码(发布新的
Context
实现) -
优化开发体验(发布
CRA
) -
底层优化(重构
Fiber
架构)
可以发现,这些迭代内容中大部分(除了底层优化)都是直接面向普通开发者的,所以React
文档(文档也是面向开发者的)中都有体现,开发者通过文档能直观的感受到React
不断迭代。
随着前端领域的发展,逐渐涌现出各种业务开发的最佳实践,比如:
-
状态管理的最佳实践
-
路由的最佳实践
-
SSR
的最佳实践
一些框架开始整合这些最佳实践(比如Next.js
、Remix
,或者国内的Umijs
...)
到了这一时期,开发者更多是通过使用这些框架间接使用React
。
感受到这一变化后,React
团队的发展方向逐渐变化 —— 从面向开发者的前端框架变为面向上层框架的元框架。
发展方向变化最明显的表现是 —— 文档中新出的特性普通开发者很少会用到,比如:
-
useTransition
-
useId
-
useMutableSource
这些特性都是作为元框架,给上层框架(或库)使用的。
上述特性虽然普通开发者很少用到,但至少文档中提及了。但随着React
不断向元框架方向发展,即使出了新特性,文档中已经不再提及了。比如:
-
useOptimistic
-
useFormStatus
Most of the above two Hook
presumably have not heard of it. They are React
actually present in the source code Hook
. However, because it is a product of the meta-framework concept, React
the document does not mention it. Instead, see the usage introduction in the Next.js documentation .
Summarize
React
The reason why there has been no stable release for a year release
is because the development direction has changed from being developer- oriented to upper-level frameworks .
The updates during this period are all oriented to the upper-level framework, so it is difficult for developers to perceive React
the changes.
But this does not mean that React
the iteration has stopped, nor can it be considered that the front-end development has stagnated.
If we must quantitatively observe React
the development of the past year, the distance from React v19
the milestone is roughly halfway: