prevDep.length undefined Cannot read properties of undefined (reading 'length') #2513
-
Code
useMyHook
User.ts
Page.ts
If I add the check of undefined of I don't know what's the root cause, any help would be greatly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@dkkb just a friendly reminder, memo is for components and useMemo for everything else I wouldn't use memo for hooks or other values |
Beta Was this translation helpful? Give feedback.
-
I think I find the root cause, it's bad to call Hooks inside conditions or loops.
|
Beta Was this translation helpful? Give feedback.
I think I find the root cause, it's bad to call Hooks inside conditions or loops.
From https://reactjs.org/link/rules-of-hooks: