I used the modular import of AG-grid, where each needed module is imported instead of the whole package:
"@ag-grid-community/core": "31.3.2",
"@ag-grid-community/react": "31.3.2",
"@ag-grid-community/styles": "31.3.2",
"@ag-grid-enterprise/core": "31.3.2"
And I implemented the following reusable component:
import { forwardRef, useMemo } from 'react'
import { AgGridReact } from '@ag-grid-community/react'
import { LicenseManager } from '@ag-grid-enterprise/core'
import '@ag-grid-community/styles/ag-grid.css'
import '@ag-grid-community/styles/ag-theme-quartz.css'
LicenseManager.setLicenseKey('xxx')
const AgGrid = forwardRef<AgGridReact, GridProps>(
return (
<div style={{height: '500px', width: '600px'}} className={'ag-theme-quartz'}>
<AgGridReact
rowData={[
{ make: 'Toyota', model: 'Celica', price: 35000 },
{ make: 'Ford', model: 'Mondeo', price: 32000 },
{ make: 'Porsche', model: 'Boxster', price: 72000 },
]}
columnDefs={[
{ headerName: 'Make', field: 'make' },
{ headerName: 'Model', field: 'model' },
{ headerName: 'Price', field: 'price' },
]}
/>
</div>
)
},
)
export default AgGrid
On browser, I get the following error:
Would you have any idea where the issue may lie? (any hint is much appreciated).
I found the issue in imports. I had to import ClientSideRowModelModule
and it worked like a charm.
import { ClientSideRowModelModule } from '@ag-grid-community/client-side-row-model'
import { ModuleRegistry } from '@ag-grid-community/core'
import { AgGridReact } from '@ag-grid-community/react'
import { LicenseManager } from '@ag-grid-enterprise/core'
ModuleRegistry.registerModules([
ClientSideRowModelModule
])