mui-x icon indicating copy to clipboard operation
mui-x copied to clipboard

[data grid] useGridRootProps should only be used inside the DataGrid/DataGridPro component

Open kh-mubashar opened this issue 5 years ago • 14 comments

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:

  1. just added the license and imported the data grid pro
  2. 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

kh-mubashar avatar Nov 19 '21 16:11 kh-mubashar

Are you in the scenario of 2245 ? (trying to run an component from x-data-grid inside de DataGridPro or vice-versa.

flaviendelangle avatar Nov 19 '21 17:11 flaviendelangle

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

kh-mubashar avatar Nov 22 '21 09:11 kh-mubashar

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 ?

flaviendelangle avatar Nov 22 '21 09:11 flaviendelangle

yes @flaviendelangle

kh-mubashar avatar Nov 22 '21 10:11 kh-mubashar

@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

kh-mubashar avatar Nov 22 '21 11:11 kh-mubashar

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.

viniciusalvess avatar May 24 '22 05:05 viniciusalvess

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 avatar May 24 '22 07:05 flaviendelangle

@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}}}
  ...
/>

viniciusalvess avatar May 25 '22 05:05 viniciusalvess

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

flaviendelangle avatar May 25 '22 06:05 flaviendelangle

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.

darrenbarklie avatar Nov 19 '22 20:11 darrenbarklie

For us it turned out to be an issue in our yarn.lock file and was resolved by:

  1. Removing the data grid package
  2. Running yarn
  3. Adding the package back
  4. 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.

adamduren avatar Apr 10 '23 15:04 adamduren

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 avatar Apr 11 '23 06:04 flaviendelangle

@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

dvZignuts avatar Apr 18 '24 05:04 dvZignuts

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:

flaviendelangle avatar Apr 18 '24 08:04 flaviendelangle