Open
Description
Hi! Thanks for all the great QOL improvements in Reselect 5, however I've found a pretty major issue with the resultEqualityCheck
option when using the weakMapMemoize
memoization. It calls the resultEqualityCheck
even if it is the first time the selector has run. This wouldn't be too bad, however this first call is called with empty objects instead of the actual result of the selector. Please see the example below. Obviously this is a bit of a contrived example using strings, but things get pretty hairy if you expect the result to be a Set
or another complex object.
const firstMessageSelector = createSelector(
[(messages) => messages[0]],
(message) => `${message}!!!`,
{
memoizeOptions: {
resultEqualityCheck: (a, b) => {
console.log("resultEqualityCheck:", { a, b });
return a === b;
},
},
}
);
const one = firstMessageSelector(["one", "two"]);
console.log("one:", one);
const two = firstMessageSelector(["two", "three"]);
console.log("two:", two);
Expected Console Output:
firstMessageSelector: one
one: one!!!
firstMessageSelector: two
resultEqualityCheck: Object { a: "one!!!", b: "two!!!" }
two: two!!!
Actual Console Output:
firstMessageSelector: one
resultEqualityCheck: Object { a: {}, b: {} }
one: one!!!
firstMessageSelector: two
resultEqualityCheck: Object { a: "one!!!", b: "two!!!" }
two: two!!!
Metadata
Metadata
Assignees
Labels
No labels