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

[docs] Static Typing for MUI React Data Grid Columns #14862

Open
johnnyreilly opened this issue Oct 7, 2024 · 4 comments
Open

[docs] Static Typing for MUI React Data Grid Columns #14862

johnnyreilly opened this issue Oct 7, 2024 · 4 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation support: docs-feedback Feedback from documentation page

Comments

@johnnyreilly
Copy link

johnnyreilly commented Oct 7, 2024

Related page

https://mui.com/x/react-data-grid/column-definition/

Kind of issue

Missing information

Issue description

I recently discovered a way to make use of static typing to ensure that columns and rows are aligned; that it's not possible to specify a field if it doesn't actually exist in the rows:

https://johnnyreilly.com/static-typing-for-mui-react-data-grid-columns

Only so many people are likely to happen upon my blog, would it be worth including this information in the actual documentation somewhere?

As an aside, I noticed this advice:

The columns prop should keep the same reference between two renders. The columns are designed to be definitions, to never change once the component is mounted. Otherwise, you take the risk of losing elements like column width or order. You can create the array outside the render function or memoize it.

In my own examples I haven't seemed to need to memoize it. Is this piece of information out of date?

Context

johnnyreilly/blog.johnnyreilly.com#956

Search keywords: Data Grid

@johnnyreilly johnnyreilly added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: docs-feedback Feedback from documentation page labels Oct 7, 2024
@zannager zannager added docs Improvements or additions to the documentation component: data grid This is the name of the generic UI component, not the React module! labels Oct 7, 2024
@michelengelen
Copy link
Member

Hey @johnnyreilly and thanks for surfacing this.
IMO the addition makes sense at least as a separate information callout in the docs, so thanks for that as well. Did you also think about the case where you need the column definition in advance?

I'll add this to the board as a request to add it to the docs.

As for our aside question: It is still relevant. Most of the time not memoizing might not be noticable at all, but when you use a big number of columns and rows this can become a problem.

@michelengelen michelengelen removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Oct 8, 2024
@johnnyreilly
Copy link
Author

johnnyreilly commented Oct 8, 2024

As for our aside question: It is still relevant. Most of the time not memoizing might not be noticable at all, but when you use a big number of columns and rows this can become a problem.

Cool - I'll put a note in about memoizing to the post

Did you also think about the case where you need the column definition in advance?

I didn't as in my use cases it's not required. Do you have a particular use case in mind? I guess if you save the column definition away to persistent storage / a database then you couldn't use this perhaps?

@michelengelen
Copy link
Member

As for our aside question: It is still relevant. Most of the time not memoizing might not be noticable at all, but when you use a big number of columns and rows this can become a problem.

Cool - I'll put a note in about memoizing to the post

Did you also think about the case where you need the column definition in advance?

I didn't as in my use cases it's not required. Do you have a particular use case in mind? I guess if you save the column definition away to persistent storage / a database then you couldn't use this perhaps?

Exactly. That's what i was thinking.

@johnnyreilly
Copy link
Author

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! docs Improvements or additions to the documentation support: docs-feedback Feedback from documentation page
Projects
Status: 🆕 Needs refinement
Development

No branches or pull requests

3 participants