本文主要是介绍React Hook useState is called in function xxx(函数名) which is neither a React function comp,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
问题:React Hook “useState” is called in function “index” which is neither a React function component or a custom React Hook function.eslint(react-hooks/rules-of-hooks)
在使用函数组件中useState的时候,偶遇这个小坑,记录一下
这里原因是因为函数的取名问题 ,function index(){}, 把函数名改成大写开头 Index() 就消除了报错信息
参考链接
这篇关于React Hook useState is called in function xxx(函数名) which is neither a React function comp的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!