简体   繁体   中英

The parent DOM element of the data grid has an empty height

import React from 'react'
import { DataGrid } from '@mui/x-data-grid'
import Box from '@mui/material/Box'

export default function ManageAdmins() {

  const columns = [
    { field: 'no.', headerName: 'no.' },
    { field: 'id', headerName: 'id' },
    { field: 'avatar', headerName: 'Avatar' },
    { field: 'name', headerName: 'Name' },
    { field: 'active', headerName: 'active?' },
    { field: 'email', headerName: 'Login email' },
    { field: 'contactEmail', headerName: 'Contact email' },
    { field: 'actions', headerName: 'Actions' },
  ]

  return (
    <Box sx={{ height: '500px', width: '500px' }}>
      <DataGrid columns={columns} rows={[]} />
    </Box>
  )
}

I am getting the following error:

MUI: useResizeContainer - The parent DOM element of the data grid has an empty height. Please make sure that this element has an intrinsic height. The grid displays with a height of 0px.

What's the problem?

you need to give it height style

<div style={{height: '300px',width: '70%'}} >
  <DataGrid ......./>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM