📜  react func 和 class 组件有什么区别 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:02:17.435000             🧑  作者: Mango

代码示例1
And so to answer our question before, you should use functional components if you are writing a presentational component which doesn’t have its own state or needs to access a lifecycle hook. Otherwise you can stick to class components or take a look into the library recompose which allows you to write functional components and enhance them with a state or lifecycle hooks with HOCs!
Source: https://djoech.medium.com/functional-vs-class-components-in-react-231e3fbd7108