- if (!nextState.isIntersecting && nextState.isHidden) {
- // It's only if we're not intersecting (i.e. offscreen) and isHidden is true
- // that either "isIntersecting" or "isHidden" matter, and then they're
- // the only things that matter (and updated ARIA attributes).
- return this.state.isIntersecting || !this.state.isHidden || nextProps.listLength !== this.props.listLength;
- } else if (nextState.isIntersecting && !this.state.isIntersecting) {
- // If we're going from a non-intersecting state to an intersecting state,
- // (i.e. offscreen to onscreen), then we definitely need to re-render
+ const isUnrendered = !this.state.isIntersecting && (this.state.isHidden || this.props.cachedHeight);
+ const willBeUnrendered = !nextState.isIntersecting && (nextState.isHidden || nextProps.cachedHeight);
+ if (!!isUnrendered !== !!willBeUnrendered) {
+ // If we're going from rendered to unrendered (or vice versa) then update