Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

MUI-Datatable: Displaying the data shows this error Cannot read properties of undefined (reading 'split')

When I added data here inside the MuiDatatable, it will show this error

Cannot read properties of undefined (reading ‘split’)

How do I fix this and display the data?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I have recreated the issue in codesandbox:
https://codesandbox.io/s/xenodochial-fog-s984v0?file=/src/App.js

Codes:

export default function App() {
  console.log(data);
  const columns = [
    {
      name: "id",
      label: "System ID", //or the order ID here
      options: {
        filter: true,
        sort: true,
        display: false
      }
    },

    {
      label: "Name",
      options: {
        filter: true,
        sort: true
      }
    },
    {
      label: "Address",
      options: {
        filter: true,
        sort: true
      }
    },

    {
      label: "Cart Items",
      options: {
        filter: true,
        sort: true
      }
    },
    {
      label: "Total Amount",
      options: {
        filter: true,
        sort: true
      }
    }
  ];
  const options = {
    filter: true,
    selectableRows: "none",
    responsive: "simple"
    // onRowClick: handleRowClick,
  };
  return (
    <div className="App">
      <ThemeProvider theme={createTheme()}>
        {" "}
        <MUIDataTable
          title={"Reports"}
          options={options}
          columns={columns}
          data={data}
        />
      </ThemeProvider>
    </div>
  );
}

>Solution :

Where is your data defined? Please make sure that data is an array of objects with structure as your columns array of the table.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading