[data grid] useGridRootProps should only be used inside the DataGrid/DataGridPro component
Duplicates
- [X] I have searched the existing issues
Latest version
- [X] I have tested the latest version
Current behavior 😯
getting this error as trying the data grid pro with the proper license
Expected behavior 🤔
everything should be fine and work properly as like before the data grid pro version
Steps to reproduce 🕹
Steps:
- just added the license and imported the data grid pro
- used the old data grid implementation 3. 4.
Context 🔦
No response
Your environment 🌎
`npx @mui/envinfo`
Don't forget to mention which browser you used.
Output from `npx @mui/envinfo` goes here.
Order ID 💳 (optional)
No response
Are you in the scenario of 2245 ? (trying to run an component from x-data-grid inside de DataGridPro or vice-versa.
Hi @flaviendelangle yes we added "@mui/x-data-grid": "^5.0.0-beta.2", and now shifting to datagrid Pro. but we are not using it inside
So you have imports of @mui/x-data-grid for pages with the free version of the Grid.
And one import of @mui/x-data-grid-pro to start using the pro version. But this usage of DataGridPro does not have any props.components that would be using @mui/x-data-grid ?
yes @flaviendelangle
@flaviendelangle thanks for the quick help I got it to work by completely removing the @mui/x-data-grid package from the app. just had to update the license and remove the old package replace it with new and update the component
I have the same issue with the "@mui/x-data-grid": "^5.11.1" package. I'm not using the pro version, and there are no pro version imports in the project and when I build the app with vite, it gives me the following error on the production error, but everything works well running the project on localhost.
Error: MUI: GridErrorHandler - An unexpected error occurred. Error: MUI: useGridRootProps should only be used inside the DataGrid/DataGridPro component.. Error: MUI: useGridRootProps should only be used inside the DataGrid/DataGridPro component.
Hi, Thanks for your contribution.
Could you provide a working reproduction, this Codesandbox template might be a good starting point.
Maybe on a new issue, because this error can hide very different problems :+1:
@flaviendelangle
I was able to get the grid working after few tests. The issue is with the custom toolbar I'm using. When remove the custom toolbar everything works as expected. I'm adding the custom toolbar code below. I hope it helps to find the issue.
export function CustomToolbar(props) {
return (
<GridToolbarContainer>
<Button variant="text" size={'small'} color={"success"} onClick={props.onNewClick}><Add/> New</Button>
<GridToolbarColumnsButton/>
{/*<GridToolbarFilterButton />*/}
{/*<GridToolbarDensitySelector/>*/}
<GridToolbarExport/>
</GridToolbarContainer>
);
}
<DataGrid
...
components={{
Toolbar: CustomToolbar,
}}
componentsProps={{toolbar: {onNewClick: handleNewClick}}}
...
/>
That's weird, your toolbar seems to be used correctly :thinking: If you have the time to provide a Codesandbox, I can have a look, otherwise I hope you find a workaround
I encountered this error when I had imported DataGrid and not DataGridPro whilst trying to use "X" features, resulting in this Uncaught Error. Aligning all imports from "@mui/x-data-grid-pro" resolved my issue.
For us it turned out to be an issue in our yarn.lock file and was resolved by:
- Removing the data grid package
- Running
yarn - Adding the package back
- Running
yarn
If that doesn't work check to make sure that you are not mixing imports from the various DataGrid packages (pro, premium, etc) and that the version numbers between mui and DataGrid are aligned.
Mixing import between pro / premium and community should not be an issue, as long as you always have the same version across the 3 packages :+1:
@flaviendelangle
I was able to get the grid working after few tests. The issue is with the custom toolbar I'm using. When remove the custom toolbar everything works as expected. I'm adding the custom toolbar code below. I hope it helps to find the issue.
export function CustomToolbar(props) { return ( <GridToolbarContainer> <Button variant="text" size={'small'} color={"success"} onClick={props.onNewClick}><Add/> New</Button> <GridToolbarColumnsButton/> {/*<GridToolbarFilterButton />*/} {/*<GridToolbarDensitySelector/>*/} <GridToolbarExport/> </GridToolbarContainer> ); } <DataGrid ... components={{ Toolbar: CustomToolbar, }} componentsProps={{toolbar: {onNewClick: handleNewClick}}} ... />
Have you got any solution for this thing Struggaling with the same thing @mui/material - ^5.14.20 @mui/x-data-grid - ^6.18.4 @mui/x-data-grid-premium - ^7.2.0
I want to use premium version of the MUI-X with the Latest one but I'm not able to But if I downgrade my @mui/x-data-grid-premium from 7.2.0 to 5.14.0 it works but all of my custom made components start shouting the type errors Need Help on this thing ASAP! My code is the same as above @flaviendelangle , @viniciusalvess
Hi,
I would advise you to open a new issue with a reproduction case I'm not working on the grid anymore and with a new issue you will get help from the current members of the grid team :+1: