Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: DH-17861: Fix the warning about IrisGridModelUpdater render not being a pure function #2249

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions packages/iris-grid/src/IrisGridModelUpdater.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react/require-default-props */
/* eslint-disable no-param-reassign */
import { useMemo } from 'react';
import { useEffect, useMemo } from 'react';
import type { dh } from '@deephaven/jsapi-types';
import { type ModelIndex, type MoveOperation } from '@deephaven/grid';
import {
Expand Down Expand Up @@ -176,18 +176,6 @@ function IrisGridModelUpdater({
},
[model, isTotalsAvailable, totalsConfig]
);
useOnChange(
function updatePendingRowCount() {
model.pendingRowCount = pendingRowCount;
},
[model, pendingRowCount]
);
useOnChange(
function updatePendingDataMap() {
model.pendingDataMap = pendingDataMap;
},
[model, pendingDataMap]
);
useOnChange(
function updateFrozenColumns() {
if (frozenColumns) {
Expand All @@ -210,6 +198,20 @@ function IrisGridModelUpdater({
},
[model, partitionConfig]
);
// These setters are wrapped in useEffect instead of useOnChange because they emit an event
// that potentially causes side effects, violating the rule that render should be a pure function.
useEffect(
function updatePendingRowCount() {
model.pendingRowCount = pendingRowCount;
},
[model, pendingRowCount]
);
useEffect(
function updatePendingDataMap() {
model.pendingDataMap = pendingDataMap;
},
[model, pendingDataMap]
);

return null;
}
Expand Down
Loading