React Hooks 理解
一个非常重要的 Hooks 原则 * Only call Hooks *at the top level*. Don’t call Hooks inside loops, conditions, or nested functions. * Only call Hooks *from React function components*. Don’t cal…
在知乎阅读全文一个非常重要的 Hooks 原则 * Only call Hooks at the top level. Don’t call Hooks inside loops, conditions, or nested functions. * Only call Hooks from React function components. Don’t call Hooks from regular JavaScript functions. (There is just one other valid place to call Hooks — your own custom Hooks. We’ll learn about them in a moment.)意思是 1、 useState, useEffect 等等方法,在顶部调…