|
108 | 108 | }() ? { passive: true } : false; |
109 | 109 |
|
110 | 110 | var UNSTABLE_MESSAGE = 'ReactList failed to reach a stable state.'; |
111 | | - var MARKER_DURATION = 100; |
112 | | - var MAX_UPDATES_PER_MARKER_DURATION = 20; |
| 111 | + var MAX_SYNC_UPDATES = 100; |
113 | 112 |
|
114 | 113 | var isEqualSubset = function isEqualSubset(a, b) { |
115 | 114 | for (var key in b) { |
|
139 | 138 | _this.cache = {}; |
140 | 139 | _this.prevPrevState = {}; |
141 | 140 | _this.unstable = false; |
| 141 | + _this.updateCounter = 0; |
142 | 142 | return _this; |
143 | 143 | } |
144 | 144 |
|
|
162 | 162 | }, { |
163 | 163 | key: 'componentDidUpdate', |
164 | 164 | value: function componentDidUpdate() { |
| 165 | + var _this2 = this; |
165 | 166 |
|
166 | 167 | // If the list has reached an unstable state, prevent an infinite loop. |
167 | 168 | if (this.unstable) return; |
168 | 169 |
|
169 | | - if (this.updateMarker && Date.now() - this.updateMarker > MARKER_DURATION) { |
170 | | - delete this.updateMarker; |
171 | | - } |
172 | | - |
173 | | - if (!this.updateMarker) { |
174 | | - this.updateMarker = Date.now(); |
175 | | - this.updatesSinceMarker = 0; |
176 | | - } |
177 | | - |
178 | | - ++this.updatesSinceMarker; |
179 | | - |
180 | | - if (this.updatesSinceMarker > MAX_UPDATES_PER_MARKER_DURATION) { |
| 170 | + if (++this.updateCounter > MAX_SYNC_UPDATES) { |
181 | 171 | this.unstable = true; |
182 | 172 | return console.error(UNSTABLE_MESSAGE); |
183 | 173 | } |
184 | 174 |
|
| 175 | + if (!this.updateCounterTimeoutId) { |
| 176 | + this.updateCounterTimeoutId = setTimeout(function () { |
| 177 | + _this2.updateCounter = 0; |
| 178 | + delete _this2.updateCounterTimeoutId; |
| 179 | + }, 0); |
| 180 | + } |
| 181 | + |
185 | 182 | this.updateFrame(); |
186 | 183 | } |
187 | 184 | }, { |
|
583 | 580 | }, { |
584 | 581 | key: 'renderItems', |
585 | 582 | value: function renderItems() { |
586 | | - var _this2 = this; |
| 583 | + var _this3 = this; |
587 | 584 |
|
588 | 585 | var _props7 = this.props, |
589 | 586 | itemRenderer = _props7.itemRenderer, |
|
596 | 593 | for (var i = 0; i < size; ++i) { |
597 | 594 | items.push(itemRenderer(from + i, i)); |
598 | 595 | }return itemsRenderer(items, function (c) { |
599 | | - return _this2.items = c; |
| 596 | + return _this3.items = c; |
600 | 597 | }); |
601 | 598 | } |
602 | 599 | }, { |
|
0 commit comments