Skip to content

Commit

Permalink
chore(table): simplify the complexity of the calculation code for bes…
Browse files Browse the repository at this point in the history
…t performance
  • Loading branch information
panvourtsis committed Oct 27, 2020
1 parent 1b53318 commit 7c61de6
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,17 @@ function Table<T>({

const columnsHasNumberArr = React.useMemo(
() =>
head(
data.map(({ cells }) =>
cells.map(({ content }) => {
return Boolean(Number.isInteger(Number(content)) || parseFloat(`${content}`));
})
)
) || [],
head(data)?.cells.map(({ content }) => {
return Boolean(Number.isInteger(Number(content)) || parseFloat(`${content}`));
}) || [],
[data]
);

const columnsWithWidth = React.useMemo(
() =>
head(
data.map(({ cells }) =>
cells.map(({ widthPercentage }) => {
return widthPercentage;
})
)
) || [],
head(data)?.cells.map(({ widthPercentage }) => {
return widthPercentage;
}) || [],
[data]
);

Expand Down

0 comments on commit 7c61de6

Please sign in to comment.