diff --git a/src/index.tsx b/src/index.tsx index 67c0c5f..8368dd5 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -183,10 +183,10 @@ export default class VirtualList extends React.PureComponent { } } - componentDidUpdate(_: Props, nextState: State) { - const {offset} = this.state; + componentDidUpdate(_: Props, prevState: State) { + const {offset, scrollChangeReason} = this.state; - if (nextState.offset !== offset && nextState.scrollChangeReason === SCROLL_CHANGE_REQUESTED) { + if (prevState.offset !== offset && scrollChangeReason === SCROLL_CHANGE_REQUESTED) { this.scrollTo(offset); } }