material-table
material-table copied to clipboard
[BUG] - Columns.render props get called twice after exporting data and clicking on edit
I have a custom render function for a column and a custom export function for data in a editable table.
When I click on export data and then on edit, all rows call the render function twice.
columns.render:
render: rowData => rowData[i] ? rowData[i]+"%" : ""
export function: `exportCsv: (columns, data) => { _.each(data, item => { return _.each(item, (i, key) => { if(key.startsWith("201")){ _.extend(item, {[key]: i+" %"}) } }) })
const fields = _.pluck(columns, 'field');
const opts = { fields };
try {
const csv = parse(data, opts);
let csvContent = "data:text/csv;charset=utf-8,"
+ csv
var encodedUri = encodeURI(csvContent);
var link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", `${moment().format('YYYY-MM-DD')}_allocation.csv`);
document.body.appendChild(link);
link.click()
} catch (err) {
console.error(err);
}
}
}}`
Column rendered at the start:

Column rendered after exporting and clicking on edit:

Everytime that I export the data and then click on edit, the render function get called 2,3,4 ecc... times.