Skip to content

Commit

Permalink
perf(services): avoid rerenders for version column
Browse files Browse the repository at this point in the history
Closes DCOS-51377
  • Loading branch information
Daniel Schmidt authored and GeorgiSTodorov committed Apr 10, 2019
1 parent ba4d5f6 commit ed03e91
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions plugins/services/src/js/columns/ServicesTableVersionColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ import Service from "../structs/Service";
import ServiceTree from "../structs/ServiceTree";
import { SortDirection } from "plugins/services/src/js/types/SortDirection";

const ServiceVersion = React.memo(
({
rawVersion,
displayVersion
}: {
rawVersion: string;
displayVersion: string;
}) => (
<TextCell>
<Tooltip content={rawVersion} wrapText={true}>
{displayVersion}
</Tooltip>
</TextCell>
)
);

export function versionRenderer(
service: Service | Pod | ServiceTree
): React.ReactNode {
Expand All @@ -17,11 +33,10 @@ export function versionRenderer(
}

return (
<TextCell>
<Tooltip content={version.rawVersion} wrapText={true}>
{version.displayVersion}
</Tooltip>
</TextCell>
<ServiceVersion
rawVersion={version.rawVersion}
displayVersion={version.displayVersion}
/>
);
}

Expand Down

0 comments on commit ed03e91

Please sign in to comment.