Skip to content

Commit 87ac421

Browse files
committed
fix: review
1 parent bf136da commit 87ac421

File tree

3 files changed

+9
-26
lines changed

3 files changed

+9
-26
lines changed

src/components/QueryResultTable/QueryResultTable.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,14 @@ type RenderCellArgs = {row: KeyValueRow; columnName: string};
6161
type RenderCell = (args: RenderCellArgs) => React.ReactNode;
6262

6363
interface CreateRenderCellParams {
64-
activeCellRef: React.RefObject<ActiveCellState>;
64+
activeCell: ActiveCellState;
6565
dispatch: React.Dispatch<ActiveCellAction>;
6666
}
6767

68-
function createRenderCell({activeCellRef, dispatch}: CreateRenderCellParams): RenderCell {
68+
function createRenderCell({activeCell, dispatch}: CreateRenderCellParams): RenderCell {
6969
return ({row, columnName}: RenderCellArgs) => {
7070
const isActive = Boolean(
71-
activeCellRef.current &&
72-
activeCellRef.current.row === row &&
73-
activeCellRef.current.columnName === columnName,
71+
activeCell && activeCell.row === row && activeCell.columnName === columnName,
7472
);
7573

7674
const value = row[columnName];
@@ -147,13 +145,10 @@ export const QueryResultTable = (props: QueryResultTableProps) => {
147145

148146
const [activeCell, dispatch] = React.useReducer(activeCellReducer, null);
149147

150-
const activeCellRef = React.useRef<ActiveCellState>(null);
151-
152-
React.useEffect(() => {
153-
activeCellRef.current = activeCell;
154-
}, [activeCell]);
155-
156-
const renderCell = React.useMemo(() => createRenderCell({activeCellRef, dispatch}), [dispatch]);
148+
const renderCell = React.useMemo(
149+
() => createRenderCell({activeCell, dispatch}),
150+
[activeCell, dispatch],
151+
);
157152

158153
const preparedColumns = React.useMemo(() => {
159154
return columns

src/containers/Tenant/Diagnostics/Network/NodeNetwork/NodeNetwork.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22

33
import {EFlag} from '../../../../../types/api/enums';
44
import {cn} from '../../../../../utils/cn';
5+
import type {NodeTooltipData} from '../NodeTooltipPopup/NodeTooltipPopup';
56

67
import './NodeNetwork.scss';
78

@@ -22,13 +23,6 @@ function getNodeModifier(connected = 0, capacity = 0) {
2223

2324
function noop() {}
2425

25-
interface NodeTooltipData {
26-
nodeId: number | string;
27-
connected?: number;
28-
capacity?: number;
29-
rack: string;
30-
}
31-
3226
interface NodeNetworkProps {
3327
onMouseEnter?: (node: HTMLDivElement, data: NodeTooltipData) => void;
3428
onMouseLeave?: () => void;

src/containers/Tenant/Diagnostics/Network/Nodes/Nodes.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,12 @@ import type {TNetNodeInfo, TNetNodePeerInfo} from '../../../../../types/api/netI
55
import {cn} from '../../../../../utils/cn';
66
import {useWithProblemsQueryParam} from '../../../../../utils/hooks/useWithProblemsQueryParam';
77
import {NodeNetwork} from '../NodeNetwork/NodeNetwork';
8+
import type {NodeTooltipData} from '../NodeTooltipPopup/NodeTooltipPopup';
89
import i18n from '../i18n';
910
import {getConnectedNodesCount, groupNodesByField} from '../utils';
1011

1112
const b = cn('network');
1213

13-
interface NodeTooltipData {
14-
nodeId: number | string;
15-
connected?: number;
16-
capacity?: number;
17-
rack: string;
18-
}
19-
2014
export interface NodesProps {
2115
nodes: Record<string, (TNetNodeInfo | TNetNodePeerInfo)[]>;
2216
isRight?: boolean;

0 commit comments

Comments
 (0)