-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[DataGrid] Restore reselect behavior #14410
Conversation
const reselectCreateSelector = createSelectorCreator({ | ||
memoize: lruMemoize, | ||
memoizeOptions: { | ||
maxSize: 1, | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perf-wise lruMemoize
stores its entries an an array, but as we use maxSize: 1
we could write a memoizer that keeps a single value in a variable instead. Don't think it's worth it enough to spend time on it however.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, they have a special case for maxSize 1
.
Deploy preview: https://deploy-preview-14410--material-ui-x.netlify.app/ |
memoize: lruMemoize, | ||
memoizeOptions: { | ||
maxSize: 1, | ||
equalityCheck: Object.is, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NaN
values were previously preventing memoization.
reselect@5
added a runtime dev check that caught this, though it wouldn't have happened if they had used Object.is
in the first place (which is the only valid equality comparison operator in JS). Also their dev checks are quite expensive, the grid could feel slower in dev mode.
Not the first time I find questionable decisions in reselect
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it makes sense to replace reselect with our own composable selectors implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice but I'd place it as low priority, I don't think it would have a big impact on perf or bundle size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking care of it!
Follow-up of #11367 (comment)