prevDep.length undefined Cannot read properties of undefined (reading 'length') #2513
Answered
by
dkkb
dkkb
asked this question in
Bug report
-
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.
Answered by
dkkb
Apr 28, 2024
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.
1 reply
-
I think I find the root cause, it's bad to call Hooks inside conditions or loops.
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
dkkb
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: