`replaceEqualDeep` returns 'b' if 'a' is [undefined]
I created a reproduction in this typescript playground: https://shorturl.at/txGY9
(The link is reliable, I shortened it to avoid hitting the character limit)
If I run this code:
it will log "false"
The issue is that this fn is used in
useMutationState
hook, and depending on select
implementation, it can cause an infinite render loop, since a [undefined] output will be considered different on every renderTS Playground - An online editor for exploring TypeScript and JavaS...
The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
8 Replies
generous-apricotOPβ’17mo ago
Help?
fascinating-indigoβ’17mo ago
I'll look into it
you are right, this test case fails:
would you like to contribute a fix ?
@Manuel Schiller this seems like a regression from when the fix from router was ported over. Judging from the commit message, I think the fix was mean to handle objects where some entries are undefined:
now handles objects with the same number of properties and one property being undefinedbut I think it broke equality for
undefined
being in arrays.sunny-greenβ’17mo ago
oh man
how can a seemingly simple fix cause that many problems
fascinating-indigoβ’17mo ago
hehe, lack of tests π
but now we can add a test-case and fix it and then I guess it doesn't come back. We need better differentiation between objects and arrays I guess
sunny-greenβ’17mo ago
"then I guess it doesn't come back"
I already thought so last time π
sunny-greenβ’17mo ago
got it now https://github.com/TanStack/query/pull/7376
fascinating-indigoβ’17mo ago
fix is shipped with
v5.34.2
. Thanks for reporting @Kalil and thanks for the fix @Manuel Schiller πgenerous-apricotOPβ’17mo ago
Nice! Good to know