我试图使用从fetchData钩子获取数据,但奇怪的是,它会产生以下错误->
Line 26:31: React Hook "useReducer" is called in function "fetchData" which is neither a React function component or a custom React Hook function react-hooks<
刚把react从v16更新到v17,得到了错误,编译失败。 Line 37:9: React Hook "Api.useAuth" is called conditionally.ReactHooks must be called in the exact same order in every component renderreact-hooks/rules-of-hooks
Line 47:
我们有没有办法在getStaticProps().中使用自定义钩子?原因是,因为我们使用内容CMS从传递API中获取数据,而且我们更容易使用自定义钩子来获取某些数据。现在,当我们调用(例如,useHomePageData中的getStaticProps()函数)时,当我们试图使用简单的对象析构来获取数据时会出现错误。Hooks can only be called
我通过useAxios钩子使用ReactAPI钩子来获取组件加载时的useEffect数据。} catch (e) { } getData();此模式在代码库中经常使用Either include them or remove the dependency array react-hooks/exhaustive-de
clickCreate("test")} id="createBtn" className="fas fa-5x fa-microphone-alt"></i> );现在,我想在函数中获取API。我不应该在函数中使用useState和useEffect,但是如何通过单击btn触发API呢?
." which is neither a React funct
我使用react useEffect从组件中的API中获取数据。dispatching user info useEffect(() => { }, []);
工作很好,我可以得到我的数据React缺少一个依赖项:“props”。要么包含它,要么删除依赖数组。但是,当任何道具发生变化时,“props”都会发生变化,因此首选的修复方法是在useEffect调用