I'm currently with a project and came up with two different set of codes and was wondering if there is a/are difference between the two.
ReactJS (latest version)
1.
columns.map(v => v.aggregate = (values) => values[0]);
2.
columns = columns.map( v => ({
...v,
aggregate : (values) => values[0]
}))
Expected result:
const columns = [
{
Header: 'ID',
accessor: 'empid',
shown: true,
width: 130
}, {
Header: 'Name',
accessor: 'name',
shown: true,
aggregate: (values) => values[0],
width: 130
}, {
Header: 'Age',
accessor: 'age',
shown: true,
aggregate: (values) => values[0],
}, {
Header: 'Email',
accessor: 'email',
shown: true,
aggregate: (values) => values[0],
width: 150
}, {
Header: 'Birthday',
accessor: 'birthday',
shown: true,
aggregate: (values) => values[0],
width: 150
}
];
I will add this to ReactTable component with aggregation pivot by id.