useShallow produces error "TypeError: Iterator value X is not an entry object" under very specific conditions #2794
Unanswered
davefallis
asked this question in
Bug report
Replies: 2 comments 14 replies
-
@davefallis would you mind creating a minimal repro on stackblitz? |
Beta Was this translation helpful? Give feedback.
0 replies
-
https://stackblitz.com/edit/vitejs-vite-bbl6sy?file=src%2FApp.tsx |
Beta Was this translation helpful? Give feedback.
14 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Bug Description
I am converting a codebase to use
useShallow
for zustand v5 and ran into the error mentioned in the title. TheX
in the title depends on the value of the value of the second array item in the selector (see example).The TypeScript playground link shows
projects
state with two items. Ifprojects
has exactly two items and the selector returns an array of two or more items, an exception is raised fromcompareMapLike
. Ifprojects
is an array with <2 or >2 items or you remove theother
state from theuseShallow
, it works as expected.Error from my projects:
I realize the stack trace is minified. The line of
compareMapLike
that is failing iszustand/src/vanilla/shallow.ts
Line 8 in 0007ef4
Reproduction Link
https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgYygUwIYzXAvnAMyghDgHIAvAVwGcYMA7AEzIChRJZFa0BlACwwAbIRADu+IiXLU6jJgHoagkeLasYATzA5e9bHAC8iVnDhhiAKzTIYNAFxwGVEACM0UANoBdU3Agw-B6Ozm4ecAA+TlQirLisrMgQDHRwPHrQOMaomNgAPHpYaAB8ABSlAJRGxXClCH4WENa2DnCeAIwANHAATN6dfgFBUI7tcRUVCQRUDLbAyXAAgmBglSZmSSnwno3Ndt1DHt5GaTR8MJml6SqiYuU0VYY1njQAdLs2+3Bvh1DeEwBuBJmdAwKhQBi1PxmPLFaFmOC8KjIZBoGg0ACE8LyCjhZkm8VYaAAHpx4Ew0AQMDF4MswEA
Beta Was this translation helpful? Give feedback.
All reactions