You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The JSUtils memorize function currently has some behavior I think is non-intuitive or borderline buggy. I have some ideas about fixing this soon, but I'm writing this here so as not to forget.
by default, if you do not define the getCacheKey function, it memoizes the function call using only the first argument as its cache key. I would expect it to use all the arguments by default.
the cache value is set using a computed property name:
{[key]: value}
this implicitly calls key.toString() to get the actual cache key. However, if the argument is an object, to key will always be [ object Object ], which would reuse the same cached value for different input.
I would rather it use a shallow-equal comparison for objects, like react's useMemo hook.
The text was updated successfully, but these errors were encountered:
Yah, I remember you bringing this up a while ago. It's good point.
And since it was brought up, A shallow equal helper has been added to the library, so we could just reuse that.
Feel free to create an issue is Jira, so we can get it done
Yah, I remember you bringing this up a while ago. It's good point.
And since it was brought up, A shallow equal helper has been added to the library, so we could just reuse that.
Feel free to create an issue is Jira, so we can get it done
The JSUtils
memorize
function currently has some behavior I think is non-intuitive or borderline buggy. I have some ideas about fixing this soon, but I'm writing this here so as not to forget.getCacheKey
function, it memoizes the function call using only the first argument as its cache key. I would expect it to use all the arguments by default.key.toString()
to get the actual cache key. However, if the argument is an object, to key will always be[ object Object ]
, which would reuse the same cached value for different input.useMemo
hook.The text was updated successfully, but these errors were encountered: