【发布时间】:2020-01-01 12:58:11
【问题描述】:
我刚刚开始使用 create-react-app 并且对 src 设置不是很熟悉。我注意到在 App.js 中,导出的 App 组件是一个函数,而不是类 App extends React.Component...
我似乎无法为其添加构造函数。有人知道我在哪里可以这样做吗?谢谢
【问题讨论】:
-
功能组件没有
constructor,只有基于类的组件可以定义constructor。