suddjian commented on a change in pull request #18729:
URL: https://github.com/apache/superset/pull/18729#discussion_r810225574
##########
File path: superset-frontend/src/components/FilterableTable/FilterableTable.tsx
##########
@@ -209,60 +197,45 @@ export default class FilterableTable extends
PureComponent<
texts: cellContent,
}).map(dimension => dimension.width);
- this.props.orderedColumnKeys.forEach((key, index) => {
+ orderedColumnKeys.forEach((key, index) => {
// 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.length + 1),
- (index + 1) * (this.list.length + 1),
- )
+ .slice(index * (list.length + 1), (index + 1) * (list.length + 1))
.reduce((a, b) => Math.max(a, b)) + PADDING;
});
return widthsByColumnKey;
- }
+ };
- getCellContent({
- cellData,
- columnKey,
- }: {
- cellData: CellDataType;
- columnKey: string;
- }) {
- if (cellData === null) {
- return 'NULL';
- }
- const content = String(cellData);
- const firstCharacter = content.substring(0, 1);
- let truncated;
- if (firstCharacter === '[') {
- truncated = '[…]';
- } else if (firstCharacter === '{') {
- truncated = '{…}';
- } else {
- truncated = '';
+ const [widthsForColumnsByKey] = useState<Record<string, number>>(
+ getWidthsForColumns(),
Review comment:
Same performance issue here, let's pass in the `getWidthsForColumns`
function as the initializer so that it only gets called when necessary.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]