Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep getting can not read properties of undefined, body2 in MUI material version 5.10.5 #42234

Closed
Sbasu2512 opened this issue May 14, 2024 · 9 comments
Assignees
Labels
component: table This is the name of the generic UI component, not the React module!

Comments

@Sbasu2512
Copy link

Sbasu2512 commented May 14, 2024

Steps to reproduce

Link to live example: (required)

Steps:

  1. Import Table and use it in a react component

Current behavior

Keep getting the following error:

TypeError: Cannot read properties of undefined (reading 'body2')

Expected behavior

Show a table

Context

import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
import TableCell from '@mui/material/TableCell';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';

<div>
        <Table>
          <TableHead>
            <TableRow>
              <TableCell>x</TableCell>
            </TableRow>
          </TableHead>
          <TableBody>
            <TableRow>
              <TableCell>y</TableCell>
            </TableRow>
          </TableBody>
        </Table>
      </div>

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
"@mui/icons-material": "^5.10.3", "@mui/material": "^5.10.5", "node": ">=16.6.0", "next": "12.3.0", browser: chrome

Search keywords: undefined body2 MUI TABLE

@Sbasu2512 Sbasu2512 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 14, 2024
@Sbasu2512
Copy link
Author

updated mui to "@mui/material": "^5.15.7", still getting the same error message.

@mnajdova
Copy link
Member

It doesn't look like this bug report has enough info for one of us to reproduce it.

Please provide a CodeSandbox (https://material-ui.com/r/issue-template-latest), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem.

Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve

@mnajdova mnajdova added component: table This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 14, 2024
@Sbasu2512
Copy link
Author

working fine in code sandbox but not in my next js app
Screenshot 2024-05-14 162149

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels May 14, 2024
@mnajdova
Copy link
Member

Can you them provide a minimal reproduction. Sharing a public GH repo would also work.

@mnajdova mnajdova added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 14, 2024
@Sbasu2512
Copy link
Author

Sbasu2512 commented May 14, 2024

here is the component:

import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
import TableCell from '@mui/material/TableCell';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import React, { useState } from 'react';
import useSWR from 'swr';

const fetcher = (...args) => fetch(...args).then((res) => res.json());

export default function SystemStatus() {
  const [isSessionRunning, setIsSessionRunning] = useState(false);
  const [isWorkflowRunning, setIsWorkflowRunning] = useState(false);
  const [isLiveScanRunning, setIsLiveScanRunning] = useState(false);
  const [isCalibrationLiveRunning, setIsCalibrationLiveRunning] =
    useState(false);
  const [isCalibrationFileRunning, setIsCalibrationFileRunning] =
    useState(false);
  const [power, setPower] = useState('');
  const [data, setData] = useState(null);
  const [cols, setCols] = useState([]);
  const [rows, setRows] = useState({});

  useSWR('/api/systemStatus', fetcher, {
    onSuccess: (data, _key, _config) => {
      if (data.status === 'SUCCESS') {
        console.log(data);
        setPower(data.result.power === 'inited' ? 'ON' : 'OFF');
        setIsSessionRunning(data.result.isScanRunning.Session);
        setIsWorkflowRunning(data.result.isScanRunning.Workflow);
        setIsLiveScanRunning(data.result.isScanRunning.livescan);
        setIsCalibrationLiveRunning(data.result.isScanRunning.calibration.live);
        setIsCalibrationFileRunning(data.result.isScanRunning.calibration.file);
        setData(data.result.telemetry_data);
      }
    },
    errorRetryInterval: 1000,
    onError: (_err, _key, _config) => {},
    dedupingInterval: 50,
    refreshInterval: 1000,
  });

  console.log(data);

  return (
    <div>
      <div>Power: {power}</div>
      <div>
        Current Scan :{' '}
        {isSessionRunning
          ? 'Session'
          : isWorkflowRunning
          ? 'Workflow'
          : isLiveScanRunning
          ? 'Live Scan'
          : isCalibrationLiveRunning
          ? 'Calibration Live'
          : isCalibrationFileRunning
          ? 'Calibration File'
          : 'No Scans are running'}{' '}
      </div>
      <div>
        <Table>
          <TableHead>
            <TableRow>
              <TableCell>x</TableCell>
            </TableRow>
          </TableHead>
          <TableBody>
            <TableRow>
              <TableCell>y</TableCell>
            </TableRow>
          </TableBody>
        </Table>
      </div>
    </div>
  );
}

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels May 14, 2024
@mnajdova
Copy link
Member

Please create a public GH repository with a reproduction, otherwise we won't be able to create a reproduction and look into what may be the problem. I am closing the issue, if you provide a reproduction I would be happy to re-open it and look into the problem.

@mnajdova mnajdova added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 14, 2024
@Sbasu2512
Copy link
Author

Made a repo but not able to reproduce the same error but some other errors are coming.

https://github.com/Sbasu2512/MuiTable

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels May 14, 2024
@github-actions github-actions bot reopened this May 14, 2024
@mnajdova
Copy link
Member

Made a repo but not able to reproduce the same error but some other errors are coming.

Can you open new issue if it is around other errors? It will help other community members to find relevant conversations in the future.

@mnajdova
Copy link
Member

If you can't reproduce this issue, it may be related to some proprietary code you have in your application, I would recommend checking this.

@zannager zannager removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: table This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

3 participants