From 0a4f2fdb08356f1014723392ca15da7659cb4d8d Mon Sep 17 00:00:00 2001 From: Phil Darnowsky Date: Mon, 10 Feb 2025 14:06:42 -0500 Subject: [PATCH] Comment on places where we can use useTableSort in the future The logic copypasta'ed into these three tables is an older version of that which was just extracted into useTableSort. It's not possible to use hooks in a class component like these three, but we leave a note in these places reminding us to use useTableSort in case we convert them to functional components in the future. --- .../src/CopyNumberVariantPage/CNVPopulationsTable.tsx | 9 ++++++--- .../MitochondrialVariantHaplogroupFrequenciesTable.tsx | 3 +++ browser/src/VariantPage/PopulationsTable.tsx | 3 +++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/browser/src/CopyNumberVariantPage/CNVPopulationsTable.tsx b/browser/src/CopyNumberVariantPage/CNVPopulationsTable.tsx index f4b3ce6e8..01bcb4a45 100644 --- a/browser/src/CopyNumberVariantPage/CNVPopulationsTable.tsx +++ b/browser/src/CopyNumberVariantPage/CNVPopulationsTable.tsx @@ -89,18 +89,21 @@ type CNVPopulationsTableState = any type CNVPopulationsTableProps = OwnPopulationsTableProps & typeof CNVPopulationsTable.defaultProps export class CNVPopulationsTable extends Component< - CNVPopulationsTableProps & { variant: CopyNumberVariant}, + CNVPopulationsTableProps & { variant: CopyNumberVariant }, CNVPopulationsTableState > { static defaultProps = { columnLabels: {}, initiallyExpandRows: false, - variant: {} + variant: {}, } - constructor(props: CNVPopulationsTableProps ) { + constructor(props: CNVPopulationsTableProps) { super(props) + // If/when we change this to a functional component, we can replace the + // following sorting logic and some other associated code by employing + // useTableSort. this.state = { sortBy: 'sf', sortAscending: false, diff --git a/browser/src/MitochondrialVariantPage/MitochondrialVariantHaplogroupFrequenciesTable.tsx b/browser/src/MitochondrialVariantPage/MitochondrialVariantHaplogroupFrequenciesTable.tsx index 85a56f609..8c82a93b1 100644 --- a/browser/src/MitochondrialVariantPage/MitochondrialVariantHaplogroupFrequenciesTable.tsx +++ b/browser/src/MitochondrialVariantPage/MitochondrialVariantHaplogroupFrequenciesTable.tsx @@ -51,6 +51,9 @@ class MitochondrialVariantHaplogroupFrequenciesTable extends Component ({ sortBy, diff --git a/browser/src/VariantPage/PopulationsTable.tsx b/browser/src/VariantPage/PopulationsTable.tsx index 479a66818..f5835c0d5 100644 --- a/browser/src/VariantPage/PopulationsTable.tsx +++ b/browser/src/VariantPage/PopulationsTable.tsx @@ -117,6 +117,9 @@ export class PopulationsTable extends Component