如何修复“未接收错误:t&quot”仅读取”在MUI DataGridPro中

发布于 2025-02-11 05:37:10 字数 3727 浏览 1 评论 0原文

我正在尝试使用MUI DataGridPro,但是我一直在遇到“错误”,而不是呈现我的数据的组件。数据是硬编码的,因此我知道数据不存在并不是问题。

我在控制台中收到以下错误:

“

列出的文件都是DataGridPro原生的所有内容,我什么也没有触摸,所以我不知道该如何修复它(我什至不确定什么是“ t”或在哪里称呼)。

这是我的DataGridPro组件的代码:

import Box from '@mui/material/Box';
import {
    DataGridPro,
    GridColumns,
    GridRowsProp,
    GridToolbar,
    LicenseInfo,
} from '@mui/x-data-grid-pro';
import { useDemoData } from '@mui/x-data-grid-generator';
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
import { styled } from '@mui/material/styles';
import FormControl from '@mui/material/FormControl';
import FormGroup from '@mui/material/FormGroup';
import Button from '@mui/material/Button';
import InputLabel from '@mui/material/InputLabel';
import MenuItem from '@mui/material/MenuItem';
import Select from '@mui/material/Select';
import { Typography } from '@mui/material';

const columns: GridColumns = [
    { field: 'voicemail', headerName: 'VOICEMAIL' },
    { field: 'patientName', headerName: 'PATIENT NAME' },
    { field: 'patientId', headerName: 'PATIENT ID' },
    { field: 'phoneNumber', headerName: 'PHONE NUMBER' },
    { field: 'callTime', headerName: 'TIME OF CALL' },
    { field: 'department', headerName: 'DEPARTMENT' },
    { field: 'status', headerName: 'STATUS' },
    { field: 'assignee', headerName: 'ASSIGNEE' },
];

const rows: GridRowsProp = [
    {
        id: 1,
        voicemail: '00:13:23',
        patientName: 'Holly Shelton',
        patientID: '78491684',
        phoneNumber: '(667) 370-2337',
        callTime: '2:30 pm EST',
        department: 'Enrollment',
        status: 'Open',
        assignee: 'Unassigned',
    },
    {
        id: 2,
        voicemail: '00:11:08',
        patientName: 'Sharon Bishop',
        patientID: '24742813',
        phoneNumber: '(345) 246-4865',
        callTime: '3:30 pm EST',
        department: 'Medical',
        status: 'Unavailable',
        assignee: 'Alex Alvarez',
    },
    {
        id: 3,
        voicemail: '00:15:08',
        patientName: 'Marcus Shelton',
        patientID: '49030689',
        phoneNumber: '(432) 753-8463',
        callTime: '4:30 pm EST',
        department: 'Medical',
        status: 'Call BAck',
        assignee: 'Pablo Lueng',
    },
];

const VoicemailGrid = (): JSX.Element => (
    <Box width="100%" height="350px">
        <Typography>Rendering</Typography>
        <DataGridPro
            rows={rows}
            columns={columns}
        />
    </Box>
);

export default VoicemailGrid;

然后在index.tsx中:

import type { FC } from 'react';
import { Container, makeStyles } from '@material-ui/core';
import type { Theme } from 'src/theme';
import Page from 'src/components/Page';
import VoicemailGrid from 'src/components/VoicemailComponents/VoicemailGrid';
import Header from './Header';

const useStyles = makeStyles((theme: Theme) => ({
    root: {
        backgroundColor: theme.palette.background.dark,
        height: '100vh',
        paddingTop: theme.spacing(3),
        paddingBottom: theme.spacing(3),
    },
}));

const PatientChart: FC<any> = () => {
    const classes = useStyles();
    return (
        <Page className={classes.root} title="Voicemail">
            <Container maxWidth="xl">
                <Header />
                <VoicemailGrid />
            </Container>
        </Page>
    );
};

PatientChart.propTypes = {

};

export default PatientChart;

I am trying to use MUI DataGridPro, but I keep getting "An error occurred" instead of the component rendering my data. The data is hard-coded, so I know it's not an issue with the data not being present.

I get the following error in the console:

Console error

The listed files are all things that are native to DataGridPro and nothing I touched, so I don't know how to go about fixing it (I'm not even sure what "t" is or where it is being called).

Here is my code for the DataGridPro component:

import Box from '@mui/material/Box';
import {
    DataGridPro,
    GridColumns,
    GridRowsProp,
    GridToolbar,
    LicenseInfo,
} from '@mui/x-data-grid-pro';
import { useDemoData } from '@mui/x-data-grid-generator';
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
import { styled } from '@mui/material/styles';
import FormControl from '@mui/material/FormControl';
import FormGroup from '@mui/material/FormGroup';
import Button from '@mui/material/Button';
import InputLabel from '@mui/material/InputLabel';
import MenuItem from '@mui/material/MenuItem';
import Select from '@mui/material/Select';
import { Typography } from '@mui/material';

const columns: GridColumns = [
    { field: 'voicemail', headerName: 'VOICEMAIL' },
    { field: 'patientName', headerName: 'PATIENT NAME' },
    { field: 'patientId', headerName: 'PATIENT ID' },
    { field: 'phoneNumber', headerName: 'PHONE NUMBER' },
    { field: 'callTime', headerName: 'TIME OF CALL' },
    { field: 'department', headerName: 'DEPARTMENT' },
    { field: 'status', headerName: 'STATUS' },
    { field: 'assignee', headerName: 'ASSIGNEE' },
];

const rows: GridRowsProp = [
    {
        id: 1,
        voicemail: '00:13:23',
        patientName: 'Holly Shelton',
        patientID: '78491684',
        phoneNumber: '(667) 370-2337',
        callTime: '2:30 pm EST',
        department: 'Enrollment',
        status: 'Open',
        assignee: 'Unassigned',
    },
    {
        id: 2,
        voicemail: '00:11:08',
        patientName: 'Sharon Bishop',
        patientID: '24742813',
        phoneNumber: '(345) 246-4865',
        callTime: '3:30 pm EST',
        department: 'Medical',
        status: 'Unavailable',
        assignee: 'Alex Alvarez',
    },
    {
        id: 3,
        voicemail: '00:15:08',
        patientName: 'Marcus Shelton',
        patientID: '49030689',
        phoneNumber: '(432) 753-8463',
        callTime: '4:30 pm EST',
        department: 'Medical',
        status: 'Call BAck',
        assignee: 'Pablo Lueng',
    },
];

const VoicemailGrid = (): JSX.Element => (
    <Box width="100%" height="350px">
        <Typography>Rendering</Typography>
        <DataGridPro
            rows={rows}
            columns={columns}
        />
    </Box>
);

export default VoicemailGrid;

And then in index.tsx:

import type { FC } from 'react';
import { Container, makeStyles } from '@material-ui/core';
import type { Theme } from 'src/theme';
import Page from 'src/components/Page';
import VoicemailGrid from 'src/components/VoicemailComponents/VoicemailGrid';
import Header from './Header';

const useStyles = makeStyles((theme: Theme) => ({
    root: {
        backgroundColor: theme.palette.background.dark,
        height: '100vh',
        paddingTop: theme.spacing(3),
        paddingBottom: theme.spacing(3),
    },
}));

const PatientChart: FC<any> = () => {
    const classes = useStyles();
    return (
        <Page className={classes.root} title="Voicemail">
            <Container maxWidth="xl">
                <Header />
                <VoicemailGrid />
            </Container>
        </Page>
    );
};

PatientChart.propTypes = {

};

export default PatientChart;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

星光不落少年眉 2025-02-18 05:37:10

尝试以下步骤

  1. 删除node_modules
  2. 删除yarn.lock/package-lock.json
  3. yarn install/npm安装
  4. 重试

Try following steps

  1. Delete node_modules
  2. Delete yarn.lock/package-lock.json
  3. yarn install/npm install
  4. try again
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文