Skip to content

Commit

Permalink
perf(services): avoid rerenders for region 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 ed03e91 commit 7d12aa8
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions plugins/services/src/js/columns/ServicesTableRegionColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ import ServiceTree from "../structs/ServiceTree";
import { SortDirection } from "plugins/services/src/js/types/SortDirection";
import ServiceTableUtil from "../utils/ServiceTableUtil";

const ServiceRegion = React.memo(({ regions }: { regions: string }) => (
<TextCell>
<Tooltip elementTag="span" wrapText={true} content={regions}>
{regions}
</Tooltip>
</TextCell>
));

export function regionRendererFactory(localRegion: string | undefined) {
return (service: Service | Pod | ServiceTree) => {
let regions: string[] = service.getRegions();
Expand All @@ -20,13 +28,7 @@ export function regionRendererFactory(localRegion: string | undefined) {
regions.push("N/A");
}

return (
<TextCell>
<Tooltip elementTag="span" wrapText={true} content={regions.join(", ")}>
{regions.join(", ")}
</Tooltip>
</TextCell>
);
return <ServiceRegion regions={regions.join(", ")} />;
};
}
export function regionSorter(
Expand Down

0 comments on commit 7d12aa8

Please sign in to comment.