Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

233
Vistas
Material-UI X: Could not find the data grid context

I'm using Data Grid Pro component from Material-UI in my React app.

I tried to create a custom toolbar for the DataGridPro component using GridToolbarColumnsButton, GridToolbarFilterButton, GridToolbarDensitySelector, and GridToolbarExport components from the same package with the DataGridPro component.

I also could use a single GridToolbar component to replace all of the four components above.

I need to create the custom toolbar component in a separate component file.

I forked the code for custom toolbar example from Material UI here https://codesandbox.io/s/wduvx and edited the code (separate the custom toolbar into a different component file) here https://codesandbox.io/s/data-grid-pro-toolbar-example-j004m

Both of the codes work fine but when I created another example from scratch here https://codesandbox.io/s/data-grid-pro-toolbar-mine-up6ik, the code produced an error. It said that Material-UI X: Could not find the data grid context (as you can see in the codesandbox).

Here are the dependencies (in package.json file):

"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.60",
"@material-ui/styles": "^4.11.4",
"@mui/x-data-grid": "^4.0.0",
"@mui/x-data-grid-pro": "^4.0.0",

What's the problem and what's the solution for this case?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You import from the wrong module, because you're using DataGridPro from @mui/x-data-grid-pro:

import { DataGridPro } from "@mui/x-data-grid-pro";

But you import the grid components in @mui/x-data-grid:

import {
  GridToolbarColumnsButton,
  GridToolbarFilterButton,
  GridToolbarDensitySelector,
  GridToolbarExport
} from "@mui/x-data-grid";

Which should have been:

import {
  GridToolbarColumnsButton,
  GridToolbarFilterButton,
  GridToolbarDensitySelector,
  GridToolbarExport
} from "@mui/x-data-grid-pro";
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda