我在使用usestate()钩子进行状态操作后遇到问题。./src/App.js
Line 6:43: React Hook "useState" is called in function "app" which is neither a Reactfunction component or a custom React Hook function react-hooks/
最近,我在我的项目中升级了react/react-dom的版本,从16.3.2升级到16.8.6,以便能够使用钩子,并且在我的代码中做了一些小改动,一切都进行得很顺利。但是我们正在使用typescript,当我尝试使用React.useState()时,typescript编译器报告说无法编译:Property 'useState' does not exist ontype 'typeof <
例如,当我这样做时:
function Foo({ children }: React.PropsWithChildren<{}>);React.PropsWithChildren是从哪里来的?我对DefinitelyTyped的工作原理了解有限,但没有node_modules/@types/react文件夹,我也从未安装过@types/react。