[英]When to use class-based component in React
在 React 16.8 中引入React Hooks以及在功能组件中控制组件状态和生命周期方法的所有新方法(例如useState
和useEffect
,功能组件和基于类的组件之间的剩余区别不再明显,因此真正的区别是什么?
There are some lifecycle methods, which can't be emulated with React Hooks(egcomponentDidCatch() ).有一些生命周期方法不能用 React Hooks 模拟(例如componentDidCatch() )。
In this cases you still need class components, but overall, you don't need them, and it's already totally fine, if you have an app without them.在这种情况下,您仍然需要类组件,但总的来说,您不需要它们,如果您的应用程序没有它们,那已经完全没问题了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.