Math.max(...array) considered harmful (#8575)

* Do not use Math.max

* Small fix
This commit is contained in:
Beto Dealmeida 2019-11-14 17:07:18 -08:00 committed by GitHub
parent 78f41b38e1
commit 2f77c9f33e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -170,10 +170,13 @@ export default class FilterableTable extends PureComponent {
).map(dimension => dimension.width);
this.props.orderedColumnKeys.forEach((key, index) => {
widthsByColumnKey[key] = Math.max(...colWidths.slice(
// we can't use Math.max(...colWidths.slice(...)) here since the number
// of elements might be bigger than the number of allowed arguments in a
// Javascript function
widthsByColumnKey[key] = colWidths.slice(
index * (this.list.size + 1),
(index + 1) * (this.list.size + 1),
)) + PADDING;
).reduce((a, b) => Math.max(a, b)) + PADDING;
});
return widthsByColumnKey;