React Hook “useState” is called in function “xxx(函数名)” which is neither a React function
报错内容
./src/Containers/device/add/index.tsx
Line 284:23: React Hook "useState" is called in function "newDeviceForm" which is neither a React function component or a custom React Hook function react-hooks/rules-of-hooks
Search for the keywords to learn more about each error.
解决方案
把报错的组件改写为class或构造函数。
- 找到报错函数
- 报错函数改为构造函数(首字母改为大写即可)