import { IconType, PendingIcon } from 'components/icon/icon';
import { SvgIconProps } from '@material-ui/core/SvgIcon';
import ArrowDownwardIcon from '@material-ui/icons/ArrowDownward';
-import { Checkbox } from '@material-ui/core';
import { createTree } from 'models/tree';
+import arraysAreCongruent from 'validators/arrays-are-congruent';
export type DataColumns<I, R> = Array<DataColumn<I, R>>;
class Component<T> extends React.Component<DataTableProps<T>> {
state: DataTableState = {};
+ componentDidMount(): void {
+ this.initializeCheckedList(this.props.items);
+ }
+
componentDidUpdate(prevProps: Readonly<DataTableProps<T>>) {
- if (prevProps.items !== this.props.items) {
+ console.log(prevProps.items, this.props.items, this.state);
+ console.log(this.props.currentRoute);
+ if (!arraysAreCongruent(prevProps.items, this.props.items)) {
this.initializeCheckedList(this.props.items);
}
}
+ componentWillUnmount(): void {
+ console.log('UNMOUNT');
+ }
+
checkBoxColumn: DataColumn<any, any> = {
name: 'checkBoxColumn',
selected: true,
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+export default function arraysAreCongruent<T>(arr1: T[], arr2: T[]): boolean {
+ if (!arr1.length || !arr2.length) return false;
+ if (arr1.length !== arr2.length) return false;
+
+ const sortedArr1 = [...arr1].sort();
+ const sortedArr2 = [...arr2].sort();
+
+ for (let i = 0; i < sortedArr1.length; i++) {
+ if (sortedArr1[i] !== sortedArr2[i]) return false;
+ }
+
+ return true;
+}