React Hook “useState” is called in function “xxx(函数名)” which is neither a React function

报错内容

1
2
3
4
./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或构造函数。

  1. 找到报错函数
    在这里插入图片描述
  2. 报错Function首字母改为大写即可
    在这里插入图片描述

本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!