proxy-memoize: Returns object which not equal by ref
I want to optimize my calculations with simplest memoization using ref but faced with problem that memoized state props not equal to previous by ref. Why? Can I compare these values by ref?
const memoize = require('proxy-memoize').memoize;
const reduxState = {
bookByName: {},
};
const selector = memoize((state) => {
if (state.bookByName !== reduxState.bookByName) {
console.log('Why not equal?');
}
});
selector(reduxState);
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 34 (34 by maintainers)
Published: https://www.npmjs.com/package/proxy-memoize/v/2.0.2
I added a failing test in #64. It looks like the bug is in v2.0.1, but not in v2.0.0. So, #60 was a bad fix, as I implied: https://twitter.com/dai_shi/status/1613867634952654849
Reduced further: https://codesandbox.io/s/frosty-sun-cssreh?file=/src/App.js
https://codesandbox.io/s/keen-heisenberg-4pg6u0?file=/src/App.js
This is so much for today. Next step would be to eliminate
createSelectorById.Gotcha. Yes, I understand it should output
200, 240.Oh, my misunderstanding then. It looks to me there’s more efficient way in proxy-memoize. Anyway, our plan is: