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

[data grid] apiRef prop and the return type of useGridApiRef() does not match in Pro and Premium versions of the grid #16116

Closed
tsmithhisler opened this issue Jan 9, 2025 · 4 comments · Fixed by #16124
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! plan: Premium Impact at least one Premium user plan: Pro Impact at least one Pro user typescript

Comments

@tsmithhisler
Copy link

tsmithhisler commented Jan 9, 2025

Steps to reproduce

Steps:

  1. Recreate this example using DataGridPro instead of DataGrid and v7.23.6 of mui-x https://mui.com/x/react-data-grid/api-object/#outside-the-data-grid
  2. See Type 'RefObject<GridApiPro>' is not assignable to type 'MutableRefObject<GridApiPro>'. error

After upgrading to v7.23.6, it appears the DataGridPro props were not updated while the DataGrid props were. See the following: v7.23.5...v7.23.6#diff-18991c189d0e0b75b030b0889cfbee75905b8b4c19361d0a4b975a1a3ac26945L418

Current behavior

Typescript fails to compile when using useGridApiRef() with DataGridPro

Expected behavior

No response

Context

No response

Your environment

No response

Search keywords: data grid pro

@tsmithhisler tsmithhisler added bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 9, 2025
@github-actions github-actions bot added the component: data grid This is the name of the generic UI component, not the React module! label Jan 9, 2025
@TrevorThomp
Copy link

Having the same issue as well:

Type 'RefObject<GridApiPremium>' is not assignable to type 'MutableRefObject<GridApiPremium>'. Types of property 'current' are incompatible. Type 'GridApiPremium | null' is not assignable to type 'GridApiPremium'. Type 'null' is not assignable to type 'GridApiPremium'.

@matzxrr
Copy link

matzxrr commented Jan 10, 2025

Casting to any is the workaround for the moment.

apiRef={apiRef as any}

@arminmeh
Copy link
Contributor

@tsmithhisler thanks for reporting this.
I will make a PR with the fix today.

In the meantime, you can use workaround from @matzxrr

@arminmeh arminmeh added typescript and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 10, 2025
@arminmeh arminmeh changed the title DataGridPro does not work with useGridApiRef() at mui-x v7.23.6 [data grid] apiRef prop and the return type of useGridApiRef() does not match in Pro and Premium versions of the grid Jan 10, 2025
@arminmeh arminmeh added plan: Pro Impact at least one Pro user plan: Premium Impact at least one Premium user labels Jan 10, 2025
Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

@tsmithhisler How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! plan: Premium Impact at least one Premium user plan: Pro Impact at least one Pro user typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants