升级MUI X包后Data Grid报父DOM元素高度为空错误的解决求助
升级MUI X包后Data Grid报父DOM元素高度为空错误的解决求助
各位大佬好,我最近升级了MUI X的相关包之后,碰到了一个挺闹心的问题:Data Grid组件一直在控制台抛出这个错误提示:
MUI X: useResizeContainer - The parent DOM element of the Data Grid has an empty height. Please make sure that this element has an intrinsic height.
虽然表格本身能正常渲染出数据,功能也没问题,但这个报错始终消不掉,想请教下有没有朋友知道怎么解决这个问题?
我的代码(Next.js 客户端组件)
"use client"; import '../ui/global.css' import Typography from '@mui/material/Typography'; import Button from '@mui/material/Button'; import { DataGrid } from "@mui/x-data-grid"; export default function Page() { // 测试用的示例数据 const rows = [ { id: 1, name: "John Doe", age: 25 }, { id: 2, name: "Jane Smith", age: 30 }, { id: 3, name: "Sam Wilson", age: 35 }, ]; const columns = [ { field: "id", headerName: "ID", width: 70 }, { field: "name", headerName: "Name", width: 150 }, { field: "age", headerName: "Age", width: 100 }, ]; return ( <div style={{ display: 'flex', flexDirection: 'column' }}> <DataGrid rows={rows} columns={columns} /> </div> ) }
当前的依赖版本(package.json)
{ "dependencies": { "@emotion/cache": "^11.13.1", "@emotion/react": "^11.13.3", "@emotion/server": "^11.11.0", "@emotion/styled": "^11.13.0", "@fontsource/roboto": "^5.1.0", "@mui/icons-material": "^7.3.1", "@mui/material": "^7.3.1", "@mui/material-nextjs": "^7.3.0", "@mui/x-charts": "^8.10.0", "@mui/x-data-grid": "^8.10.0", "@mui/x-date-pickers": "^8.10.0", "dayjs": "^1.11.13", "next": "^15.1.8", "next-ws": "^2.0.7", "python-shell": "^5.0.0", "react": "^19.0.0-rc.1", "react-dom": "^19.0.0-rc.1", "react-py": "^1.11.2", "ts-node": "^10.9.2", "ws": "^8.18.0" }, "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint" }, "devDependencies": { "@types/node": "24.2.0", "@types/react": "19.1.9", "eslint": "9.32.0", "eslint-config-next": "15.4.6", "typescript": "5.9.2" } }
我自己也检查了包裹DataGrid的父容器,现在用的是display: flex; flexDirection: column的div,但还是会触发这个错误,有没有人遇到过类似的情况,或者有什么排查方向可以给我指指路呀?
内容来源于stack exchange
相关产品推荐
相关产品推荐

