-
Notifications
You must be signed in to change notification settings - Fork 673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression when using lodash for an unbounded cache and reselect 4.0 #376
Comments
A quick look at the code shows that my problem is related to this change. |
I can confirm the same issue here. Tested with both versions. Your pull @mosho1. |
From lodash docs:
In the test case, the first argument is the state object, and all calls return the same memoized value after the first call as expected. This should make the test cases pass by having memoization done with the ids as the cache keys:
|
In this solution, we mix the map cache key definition and the memoization function. The purpose of the hashFn function is to compute the map cache key. const customSelectorCreator = createSelectorCreator(
customMemoize, // function to be used to memoize resultFunc
option1, // option1 will be passed as second argument to customMemoize
option2, // option2 will be passed as third argument to customMemoize
option3 // option3 will be passed as fourth argument to customMemoize
) Therefore, memoize should use my hashFn function to get the map cache key. |
Yes, you are right. This PR makes the required change: #359 |
Went out in https://github.com/reduxjs/reselect/releases/tag/v4.0.0 . |
@markerikson What do you mean? The PR was released in that tag? I believe the issue was raised due to that tag. |
You're right, my bad. I was looking at the wrong commit diff and got confused, sorry! |
I just tried making this change on top of
with this error:
I think the issue may be specifically related to use of Lodash here, but I'm not sure. Given that, I'm not comfortable trying to make this change right now. If someone else would like to take a look and figure out what's going on, please do so. |
the same issue with lodash/fp: option1 is not a function:
works in reselect 2 and 3, but not in 4 |
FWIW, this issue is extremely low priority atm. If someone wants to look at what's going on here that would be great! |
- Add documentation regarding new features. - Redo `CodeSandbox` examples to align better with documentation. Solves reduxjs#598. - Fix GitHub workflow badge URL reduxjs#628. - Add instructions for `bun` and `pnpm`. Solves reduxjs#621. - Fix minor type issues regarding `createStructuredSelector`. Solves reduxjs#499. - `argsMemoize` and `argsMemoizeOptions` solve reduxjs#359. - Remove `Redux` legacy patterns including `connect` and `switch` statements from docs. Solves reduxjs#515. - Replace legacy code patterns with modern syntax like `useSelector` and functional components. - Implementation of `argsMemoize` solves reduxjs#376. - Document order of execution in `Reselect`. Solves reduxjs#455. - Add benchmarks to confirm the info inside the documentation. - Add more type tests with `vitest`. - Fix more hover preview issues with types.
I believe this has been reoslved by #626 due to the implementation of |
I have the following unit test inspired from the reselect documentation (Use memoize function from lodash for an unbounded cache section)
All the tests passed with reselect 3.0.1.
After upgrading to reselect 4.0, 6 tests keep on failing.
It seems that the hash function is called once. Therefore the selector always returns the same value (instead of the right value).
Is there anything wrong with my code ?
The text was updated successfully, but these errors were encountered: