Skip to content

Commit 28430b9

Browse files
Merge pull request #73 from developerdizzle/FixVersion2.2.3
[fix] Rebuilds lib
2 parents 42dbd7d + af76ab2 commit 28430b9

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/VirtualList.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ var VirtualList = function VirtualList(options) {
5353

5454
var _this = _possibleConstructorReturn(this, (vlist.__proto__ || Object.getPrototypeOf(vlist)).call(this, props));
5555

56+
_this._isMounted = false;
57+
58+
5659
_this.options = _extends({
5760
container: typeof window !== 'undefined' ? window : undefined
5861
}, options);
@@ -82,17 +85,25 @@ var VirtualList = function VirtualList(options) {
8285
// get first and lastItemIndex
8386
var state = (0, _getVisibleItemBounds2.default)(list, container, items, itemHeight, itemBuffer);
8487

88+
if (state === undefined) {
89+
return;
90+
}
91+
8592
if (state.firstItemIndex > state.lastItemIndex) {
8693
return;
8794
}
8895

89-
if (state !== undefined && (state.firstItemIndex !== this.state.firstItemIndex || state.lastItemIndex !== this.state.lastItemIndex)) {
96+
if (state.firstItemIndex !== this.state.firstItemIndex || state.lastItemIndex !== this.state.lastItemIndex) {
9097
this.setState(state);
9198
}
9299
}
93100
}, {
94101
key: 'refreshState',
95102
value: function refreshState() {
103+
if (!this._isMounted) {
104+
return;
105+
}
106+
96107
var _props = this.props,
97108
itemHeight = _props.itemHeight,
98109
items = _props.items,
@@ -101,6 +112,11 @@ var VirtualList = function VirtualList(options) {
101112

102113
this.setStateIfNeeded(this.domNode, this.options.container, items, itemHeight, itemBuffer);
103114
}
115+
}, {
116+
key: 'componentWillMount',
117+
value: function componentWillMount() {
118+
this._isMounted = true;
119+
}
104120
}, {
105121
key: 'componentDidMount',
106122
value: function componentDidMount() {
@@ -117,6 +133,8 @@ var VirtualList = function VirtualList(options) {
117133
}, {
118134
key: 'componentWillUnmount',
119135
value: function componentWillUnmount() {
136+
this._isMounted = false;
137+
120138
// remove events
121139
this.options.container.removeEventListener('scroll', this.refreshState);
122140
this.options.container.removeEventListener('resize', this.refreshState);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-virtual-list",
3-
"version": "2.2.3",
3+
"version": "2.2.4",
44
"description": "Super simple virtualized list React higher-order component",
55
"main": "lib/VirtualList.js",
66
"directories": {

0 commit comments

Comments
 (0)