Master
语言 & 框架

React Hooks

NOT ON THE CURRENT EDITION
This blip is not on the current edition of the Radar. If it was on one of the last few editions it is likely that it is still relevant. If the blip is older it might no longer be relevant and our assessment might be different today. Unfortunately, we simply don't have the bandwidth to continuously review blips from previous editions of the RadarUnderstand more
Published: Nov 20, 2019
Last Updated: May 19, 2020
May 2020
采纳?

React Hooks 引入了一种管理状态逻辑的新方法; 鉴于 React 组件相比较类来说更接近于函数, Hooks 接受了这一点并将状态传给函数,而不是将函数作为方法传给带有状态的类。 基于我们的经验,Hooks 提高了组件之间功能的重用性和代码的可读性。 考虑到 Hooks 使用 React Test RendererReact Testing Library改进了可测试性,以及不断增长的社区支持,我们将其作为我们的首选方法。

Nov 2019
试验?

今年年初,React Hooks成为了流行的JavaScript框架。它无需编写类就可以使用状态和其他React功能,从而提供了一种比使用高阶组件或render-props更简洁的方法。诸如Material UIApollo之类的库已经切换到使用Hooks了。测试Hooks时会遇到一些问题,特别是使用Enzyme时,这能帮助我们重新评估是否选择Enzyme作为工具。