Skip to content
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] Move virtualization logic to hook #3079

Merged
merged 1 commit into from
Nov 3, 2021

Conversation

m4theushw
Copy link
Member

Part of #2946

The same idea of #3078 but with the main virtualization.

@m4theushw m4theushw added the component: data grid This is the name of the generic UI component, not the React module! label Nov 3, 2021
const VirtualScrollerContentRoot = styled('div', {
name: 'MuiDataGrid',
slot: 'VirtualScrollerContent',
overridesResolver: (props, styles) => styles.virtualScrollerContent,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flaviendelangle
Copy link
Member

flaviendelangle commented Nov 3, 2021

Do we agree that it is only a copy / paste on the logic and 2-3 function wrappers ?
Le global logic seems good to me.
I'm just not a huge fan of creating function like getRootProps if they just return variables that are computed during the render anyway. I don't see the gain compared to simplify return rootProps.

@m4theushw
Copy link
Member Author

Do we agree that it is only a copy / paste on the logic and 2-3 function wrappers ?

@flaviendelangle Yes, the code of the hook is a literal copy and paste.

I'm just not a huge fan of creating function like getRootProps if they just return variables that are computed during the render anyway. I don't see the gain compared to simplify return rootProps.

This is a pattern heavily used in the core for unstyled components: https://github.com/mui-org/material-ui/blob/eb01f34ed9b680f4b893cacd73b846c2284a429a/packages/mui-core/src/AutocompleteUnstyled/useAutocomplete.js#L1028

Downshift and other libs also used it: https://github.com/downshift-js/downshift#prop-getters

For now, it could return a normal object. However, returning a function could be useful to sanitize the props that are passed to the component.

@m4theushw m4theushw merged commit 92605f7 into mui:next Nov 3, 2021
@m4theushw m4theushw deleted the virtual-scroller-hook branch November 3, 2021 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants