-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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] DataGrid gives warning about apiRef.current #15507
Comments
Hey @entaildevops ... could you make that codesandbox public please? |
@michelengelen done =) |
any update on this @michelengelen? |
not yet ... sry ... i had my hands full with other stuff, but will get to test it this week. |
All right ... I have looked into this and the main problem is that the children if the dialog will get unmounted and the apiRef gets "cleared" to prevent bugs due to a lingering api. To prevent that you can use the |
Yes, looks like this is sufficient. Thanks! Btw, it looks like this keepMounted prop is not listed in the API docs for the Dialog. This is probably because the DialogProps extend ModalProps, and for Modal the keepMounted is listed in its API docs. Nevertheless, according to the docs there is no possibility to use the keepMounted for the dialog.. |
I agree that we could possibly do a bit better on mentioning that. We did a similar thing for the Group extension for 'Tree Data' and 'Row grouping'. Great that this solves your use case ... i'll close the issue! 👍🏼 |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note @entaildevops 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. |
The problem in depth
I am using DataGridPro in Dialog. When the dialog is opened for a second time, the following warning is printed to console:
"Warning: Failed prop type: The prop
apiRef.current
is marked as required inForwardRef(DataGridPro)
, but its value isnull
."Here is a simplified demo that demonstrates the issue. I also made a code sandbox demo.
I have a parent component for controlling when the dialog is open/closed.
And a child component for the actual dialog and DataGrid:
Please explain why the apiRef becomes null briefly when the dialog is reopened and causes the warning. The functionality seems fine though, but I would like to get rid of the warning (and also understand the reason for it). Thanks!
Your environment
System:
OS: Windows 11 10.0.22631
Binaries:
Node: 18.16.0 - C:\Program Files\nodejs\node.EXE
npm: 9.5.1 - C:\Program Files\nodejs\npm.CMD
pnpm: Not Found
Browsers:
Chrome: Not Found
Edge: Chromium (127.0.2651.86)
npmPackages:
@emotion/react: ^11.11.4 => 11.11.4
@emotion/styled: ^11.11.5 => 11.11.5
@mui/base: 5.0.0-beta.40
@mui/core-downloads-tracker: 5.15.20
@mui/icons-material: ^5.15.20 => 5.15.20
@mui/material: ^5.15.20 => 5.15.20
@mui/private-theming: 5.15.20
@mui/styled-engine: 5.15.14
@mui/system: 5.15.20
@mui/types: 7.2.16
@mui/utils: 5.16.6
@mui/x-data-grid: ^7.6.2 => 7.22.2
@mui/x-data-grid-pro: ^7.22.2 => 7.22.2
@mui/x-date-pickers: ^7.16.0 => 7.16.0
@mui/x-internals: 7.16.0
@mui/x-license: 7.21.0
@types/react: ^18.2.66 => 18.3.3
react: ^18.2.0 => 18.3.1
react-dom: ^18.2.0 => 18.3.1
typescript: ^5.2.2 => 5.4.5
problem is reproduced on both Edge and Chrome
Search keywords: apiRef.current
Order ID: 98745
The text was updated successfully, but these errors were encountered: