Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fix Typescript error when customizing MUI X Data Grid in createTheme

I want to customize my DataGridPro table (MUI component) in the theme. However, when I MuiDataGrid to components object, I get a TS error:

Object literal may only specify known properties, and 'MuiDataGrid' does not exist in type 'Components'.ts(2322)

Codesandbox: https://codesandbox.io/s/datagriddemo-material-demo-forked-vedcm

How do I fix the error? I spent 2 hours looking everywhere without success.

like image 811
justdvl Avatar asked Jun 07 '26 13:06

justdvl


1 Answers

I got answer to this question on MUI github issue page: https://github.com/mui-org/material-ui-x/issues/1755#issuecomment-945650984

The solution is to import theme augmentation like so:

import type {} from '@mui/x-data-grid-pro/themeAugmentation';

as described in: https://mui.com/components/data-grid/getting-started/#typescript

like image 158
justdvl Avatar answered Jun 10 '26 05:06

justdvl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!