I am doing a ReactJS Application, working with a rest API, and I want to test the node packages MUI-datatables, to display a list.
But I get the error : 'TypeError: Cannot read property 'customBodyRender' of undefined'
Here is my code :
render() {
const columns = ["URL", "Modele"];
const test = [
["Joe James", "Test Corp", "Yonkers", "NY"]
];
const options = {
filterType: 'checkbox',
};
return (
<div>
<MUIDataTable title={"Offree"} data={test} columns={columns} options={options}/>
</div>)
}
}
Thanks for your answer !
You'll have to match the amount of items in columns
with the amount of items in test
. Currently, you have two more items in your data, compared to your columns. For example, the following will fix:
const columns = ["URL", "Modele", "thirdColumn", "fourthColumn"];
If you don't want to display the third and fourth column, you can set display: false
in your column options:
const columns = [
{
name: "URL",
options: {
display: true
}
},
{
name: "Modele",
options: {
display: true
}
},
{
name: "thirdColumn",
options: {
display: false
}
},
{
name: "fourthColumn",
options: {
display: false
}
}
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With