From 944f0edcb231798e8678cd7b3d7475aa22ce9ab7 Mon Sep 17 00:00:00 2001 From: Benj Kamm Date: Tue, 18 Feb 2020 14:25:13 -0600 Subject: [PATCH] Fix infinite loop with externally controlled scroll --- src/FixedDataTable.js | 6 +++--- src/FixedDataTableContainer.js | 2 +- src/FixedDataTableStore.js | 4 +--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/FixedDataTable.js b/src/FixedDataTable.js index 2cc039d5..d78ea3ce 100644 --- a/src/FixedDataTable.js +++ b/src/FixedDataTable.js @@ -1113,7 +1113,7 @@ class FixedDataTable extends React.Component { /** * Calls the user specified scroll callbacks -- onScrollStart, onScrollEnd, onHorizontalScroll, and onVerticalScroll. */ - _didScroll = (/* !object */ nextProps) => { + _didScroll = (/* !object */ prevProps) => { const { onScrollStart, scrollX, @@ -1121,7 +1121,7 @@ class FixedDataTable extends React.Component { onHorizontalScroll, onVerticalScroll, tableSize: { ownerHeight }, - } = nextProps; + } = this.props; const { endRowIndex: oldEndRowIndex, @@ -1129,7 +1129,7 @@ class FixedDataTable extends React.Component { scrollX: oldScrollX, scrollY: oldScrollY, tableSize: { ownerHeight: oldOwnerHeight }, - } = this.props; + } = prevProps; // check if scroll values have changed - we have an extra check on NaN because (NaN !== NaN) const ownerHeightChanged = ownerHeight !== oldOwnerHeight && !(isNaN(ownerHeight) && isNaN(oldOwnerHeight)); diff --git a/src/FixedDataTableContainer.js b/src/FixedDataTableContainer.js index 26e2e2f9..269ad6a9 100644 --- a/src/FixedDataTableContainer.js +++ b/src/FixedDataTableContainer.js @@ -68,8 +68,8 @@ class FixedDataTableContainer extends React.Component { render() { return ( diff --git a/src/FixedDataTableStore.js b/src/FixedDataTableStore.js index d9222629..156a2be3 100644 --- a/src/FixedDataTableStore.js +++ b/src/FixedDataTableStore.js @@ -15,7 +15,5 @@ import reducers from 'reducers' import { createStore } from 'redux' export default { - get: () => { - return createStore(reducers) - }, + get: () => createStore(reducers) };