react-window 1.8.10 → 2.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +9 -161
  2. package/dist/react-window.cjs +22 -0
  3. package/dist/react-window.d.ts +217 -0
  4. package/dist/react-window.js +812 -0
  5. package/docs/assets/index-DlGpNu0r.css +1 -0
  6. package/docs/assets/index-fVOw1dKb.js +67 -0
  7. package/docs/data/addresses.json +7954 -0
  8. package/docs/data/contacts.json +4202 -0
  9. package/docs/data/names.json +1002 -0
  10. package/docs/favicon.svg +16 -0
  11. package/docs/generated/README.md +1 -0
  12. package/docs/generated/code-snippets/CellComponent.json +4 -0
  13. package/docs/generated/code-snippets/FixedHeightList.json +4 -0
  14. package/docs/generated/code-snippets/FixedHeightRowComponent.json +4 -0
  15. package/docs/generated/code-snippets/FlexboxLayout.json +4 -0
  16. package/docs/generated/code-snippets/Grid.json +4 -0
  17. package/docs/generated/code-snippets/ListVariableRowHeights.json +4 -0
  18. package/docs/generated/code-snippets/columnWidth.json +4 -0
  19. package/docs/generated/code-snippets/gridRefClickEventHandler.json +3 -0
  20. package/docs/generated/code-snippets/listRefClickEventHandler.json +3 -0
  21. package/docs/generated/code-snippets/rowHeight.json +4 -0
  22. package/docs/generated/code-snippets/useGridRef.json +4 -0
  23. package/docs/generated/code-snippets/useGridRefImport.json +3 -0
  24. package/docs/generated/code-snippets/useListRef.json +4 -0
  25. package/docs/generated/code-snippets/useListRefImport.json +3 -0
  26. package/docs/generated/js-docs/Grid.json +314 -0
  27. package/docs/generated/js-docs/List.json +266 -0
  28. package/docs/index.html +30 -0
  29. package/docs/og.html +42 -0
  30. package/docs/og.png +0 -0
  31. package/docs/stats.html +4949 -0
  32. package/docs/svgs/checkbox-checked.svg +1 -0
  33. package/docs/svgs/checkbox-indeterminate.svg +1 -0
  34. package/docs/svgs/checkbox-unchecked.svg +1 -0
  35. package/docs/svgs/github.svg +3 -0
  36. package/docs/svgs/npm.svg +1 -0
  37. package/docs/svgs/radio-checked.svg +1 -0
  38. package/docs/svgs/radio-unchecked.svg +1 -0
  39. package/package.json +70 -90
  40. package/LICENSE.md +0 -21
  41. package/dist/index-dev.umd.js +0 -2
  42. package/dist/index-dev.umd.js.map +0 -1
  43. package/dist/index-prod.umd.js +0 -2
  44. package/dist/index-prod.umd.js.map +0 -1
  45. package/dist/index.cjs.js +0 -2087
  46. package/dist/index.cjs.js.flow +0 -3
  47. package/dist/index.cjs.js.map +0 -1
  48. package/dist/index.esm.js +0 -2076
  49. package/dist/index.esm.js.flow +0 -3
  50. package/dist/index.esm.js.map +0 -1
  51. package/src/FixedSizeGrid.js +0 -244
  52. package/src/FixedSizeList.js +0 -137
  53. package/src/VariableSizeGrid.js +0 -507
  54. package/src/VariableSizeList.js +0 -317
  55. package/src/areEqual.js +0 -18
  56. package/src/createGridComponent.js +0 -919
  57. package/src/createListComponent.js +0 -745
  58. package/src/domHelpers.js +0 -72
  59. package/src/index.js +0 -9
  60. package/src/shallowDiffers.js +0 -17
  61. package/src/shouldComponentUpdate.js +0 -16
  62. package/src/timer.js +0 -37
@@ -1,137 +0,0 @@
1
- // @flow
2
-
3
- import createListComponent from './createListComponent';
4
-
5
- import type { Props, ScrollToAlign } from './createListComponent';
6
-
7
- type InstanceProps = any;
8
-
9
- const FixedSizeList = createListComponent({
10
- getItemOffset: ({ itemSize }: Props<any>, index: number): number =>
11
- index * ((itemSize: any): number),
12
-
13
- getItemSize: ({ itemSize }: Props<any>, index: number): number =>
14
- ((itemSize: any): number),
15
-
16
- getEstimatedTotalSize: ({ itemCount, itemSize }: Props<any>) =>
17
- ((itemSize: any): number) * itemCount,
18
-
19
- getOffsetForIndexAndAlignment: (
20
- { direction, height, itemCount, itemSize, layout, width }: Props<any>,
21
- index: number,
22
- align: ScrollToAlign,
23
- scrollOffset: number,
24
- instanceProps: InstanceProps,
25
- scrollbarSize: number
26
- ): number => {
27
- // TODO Deprecate direction "horizontal"
28
- const isHorizontal = direction === 'horizontal' || layout === 'horizontal';
29
- const size = (((isHorizontal ? width : height): any): number);
30
- const lastItemOffset = Math.max(
31
- 0,
32
- itemCount * ((itemSize: any): number) - size
33
- );
34
- const maxOffset = Math.min(
35
- lastItemOffset,
36
- index * ((itemSize: any): number)
37
- );
38
- const minOffset = Math.max(
39
- 0,
40
- index * ((itemSize: any): number) -
41
- size +
42
- ((itemSize: any): number) +
43
- scrollbarSize
44
- );
45
-
46
- if (align === 'smart') {
47
- if (
48
- scrollOffset >= minOffset - size &&
49
- scrollOffset <= maxOffset + size
50
- ) {
51
- align = 'auto';
52
- } else {
53
- align = 'center';
54
- }
55
- }
56
-
57
- switch (align) {
58
- case 'start':
59
- return maxOffset;
60
- case 'end':
61
- return minOffset;
62
- case 'center': {
63
- // "Centered" offset is usually the average of the min and max.
64
- // But near the edges of the list, this doesn't hold true.
65
- const middleOffset = Math.round(
66
- minOffset + (maxOffset - minOffset) / 2
67
- );
68
- if (middleOffset < Math.ceil(size / 2)) {
69
- return 0; // near the beginning
70
- } else if (middleOffset > lastItemOffset + Math.floor(size / 2)) {
71
- return lastItemOffset; // near the end
72
- } else {
73
- return middleOffset;
74
- }
75
- }
76
- case 'auto':
77
- default:
78
- if (scrollOffset >= minOffset && scrollOffset <= maxOffset) {
79
- return scrollOffset;
80
- } else if (scrollOffset < minOffset) {
81
- return minOffset;
82
- } else {
83
- return maxOffset;
84
- }
85
- }
86
- },
87
-
88
- getStartIndexForOffset: (
89
- { itemCount, itemSize }: Props<any>,
90
- offset: number
91
- ): number =>
92
- Math.max(
93
- 0,
94
- Math.min(itemCount - 1, Math.floor(offset / ((itemSize: any): number)))
95
- ),
96
-
97
- getStopIndexForStartIndex: (
98
- { direction, height, itemCount, itemSize, layout, width }: Props<any>,
99
- startIndex: number,
100
- scrollOffset: number
101
- ): number => {
102
- // TODO Deprecate direction "horizontal"
103
- const isHorizontal = direction === 'horizontal' || layout === 'horizontal';
104
- const offset = startIndex * ((itemSize: any): number);
105
- const size = (((isHorizontal ? width : height): any): number);
106
- const numVisibleItems = Math.ceil(
107
- (size + scrollOffset - offset) / ((itemSize: any): number)
108
- );
109
- return Math.max(
110
- 0,
111
- Math.min(
112
- itemCount - 1,
113
- startIndex + numVisibleItems - 1 // -1 is because stop index is inclusive
114
- )
115
- );
116
- },
117
-
118
- initInstanceProps(props: Props<any>): any {
119
- // Noop
120
- },
121
-
122
- shouldResetStyleCacheOnItemSizeChange: true,
123
-
124
- validateProps: ({ itemSize }: Props<any>): void => {
125
- if (process.env.NODE_ENV !== 'production') {
126
- if (typeof itemSize !== 'number') {
127
- throw Error(
128
- 'An invalid "itemSize" prop has been specified. ' +
129
- 'Value should be a number. ' +
130
- `"${itemSize === null ? 'null' : typeof itemSize}" was specified.`
131
- );
132
- }
133
- }
134
- },
135
- });
136
-
137
- export default FixedSizeList;
@@ -1,507 +0,0 @@
1
- // @flow
2
-
3
- import createGridComponent from './createGridComponent';
4
-
5
- import type { Props, ScrollToAlign } from './createGridComponent';
6
-
7
- const DEFAULT_ESTIMATED_ITEM_SIZE = 50;
8
-
9
- type VariableSizeProps = {|
10
- estimatedColumnWidth: number,
11
- estimatedRowHeight: number,
12
- ...Props<any>,
13
- |};
14
-
15
- type itemSizeGetter = (index: number) => number;
16
- type ItemType = 'column' | 'row';
17
-
18
- type ItemMetadata = {|
19
- offset: number,
20
- size: number,
21
- |};
22
- type ItemMetadataMap = { [index: number]: ItemMetadata };
23
- type InstanceProps = {|
24
- columnMetadataMap: ItemMetadataMap,
25
- estimatedColumnWidth: number,
26
- estimatedRowHeight: number,
27
- lastMeasuredColumnIndex: number,
28
- lastMeasuredRowIndex: number,
29
- rowMetadataMap: ItemMetadataMap,
30
- |};
31
-
32
- const getEstimatedTotalHeight = (
33
- { rowCount }: Props<any>,
34
- { rowMetadataMap, estimatedRowHeight, lastMeasuredRowIndex }: InstanceProps
35
- ) => {
36
- let totalSizeOfMeasuredRows = 0;
37
-
38
- // Edge case check for when the number of items decreases while a scroll is in progress.
39
- // https://github.com/bvaughn/react-window/pull/138
40
- if (lastMeasuredRowIndex >= rowCount) {
41
- lastMeasuredRowIndex = rowCount - 1;
42
- }
43
-
44
- if (lastMeasuredRowIndex >= 0) {
45
- const itemMetadata = rowMetadataMap[lastMeasuredRowIndex];
46
- totalSizeOfMeasuredRows = itemMetadata.offset + itemMetadata.size;
47
- }
48
-
49
- const numUnmeasuredItems = rowCount - lastMeasuredRowIndex - 1;
50
- const totalSizeOfUnmeasuredItems = numUnmeasuredItems * estimatedRowHeight;
51
-
52
- return totalSizeOfMeasuredRows + totalSizeOfUnmeasuredItems;
53
- };
54
-
55
- const getEstimatedTotalWidth = (
56
- { columnCount }: Props<any>,
57
- {
58
- columnMetadataMap,
59
- estimatedColumnWidth,
60
- lastMeasuredColumnIndex,
61
- }: InstanceProps
62
- ) => {
63
- let totalSizeOfMeasuredRows = 0;
64
-
65
- // Edge case check for when the number of items decreases while a scroll is in progress.
66
- // https://github.com/bvaughn/react-window/pull/138
67
- if (lastMeasuredColumnIndex >= columnCount) {
68
- lastMeasuredColumnIndex = columnCount - 1;
69
- }
70
-
71
- if (lastMeasuredColumnIndex >= 0) {
72
- const itemMetadata = columnMetadataMap[lastMeasuredColumnIndex];
73
- totalSizeOfMeasuredRows = itemMetadata.offset + itemMetadata.size;
74
- }
75
-
76
- const numUnmeasuredItems = columnCount - lastMeasuredColumnIndex - 1;
77
- const totalSizeOfUnmeasuredItems = numUnmeasuredItems * estimatedColumnWidth;
78
-
79
- return totalSizeOfMeasuredRows + totalSizeOfUnmeasuredItems;
80
- };
81
-
82
- const getItemMetadata = (
83
- itemType: ItemType,
84
- props: Props<any>,
85
- index: number,
86
- instanceProps: InstanceProps
87
- ): ItemMetadata => {
88
- let itemMetadataMap, itemSize, lastMeasuredIndex;
89
- if (itemType === 'column') {
90
- itemMetadataMap = instanceProps.columnMetadataMap;
91
- itemSize = ((props.columnWidth: any): itemSizeGetter);
92
- lastMeasuredIndex = instanceProps.lastMeasuredColumnIndex;
93
- } else {
94
- itemMetadataMap = instanceProps.rowMetadataMap;
95
- itemSize = ((props.rowHeight: any): itemSizeGetter);
96
- lastMeasuredIndex = instanceProps.lastMeasuredRowIndex;
97
- }
98
-
99
- if (index > lastMeasuredIndex) {
100
- let offset = 0;
101
- if (lastMeasuredIndex >= 0) {
102
- const itemMetadata = itemMetadataMap[lastMeasuredIndex];
103
- offset = itemMetadata.offset + itemMetadata.size;
104
- }
105
-
106
- for (let i = lastMeasuredIndex + 1; i <= index; i++) {
107
- let size = itemSize(i);
108
-
109
- itemMetadataMap[i] = {
110
- offset,
111
- size,
112
- };
113
-
114
- offset += size;
115
- }
116
-
117
- if (itemType === 'column') {
118
- instanceProps.lastMeasuredColumnIndex = index;
119
- } else {
120
- instanceProps.lastMeasuredRowIndex = index;
121
- }
122
- }
123
-
124
- return itemMetadataMap[index];
125
- };
126
-
127
- const findNearestItem = (
128
- itemType: ItemType,
129
- props: Props<any>,
130
- instanceProps: InstanceProps,
131
- offset: number
132
- ) => {
133
- let itemMetadataMap, lastMeasuredIndex;
134
- if (itemType === 'column') {
135
- itemMetadataMap = instanceProps.columnMetadataMap;
136
- lastMeasuredIndex = instanceProps.lastMeasuredColumnIndex;
137
- } else {
138
- itemMetadataMap = instanceProps.rowMetadataMap;
139
- lastMeasuredIndex = instanceProps.lastMeasuredRowIndex;
140
- }
141
-
142
- const lastMeasuredItemOffset =
143
- lastMeasuredIndex > 0 ? itemMetadataMap[lastMeasuredIndex].offset : 0;
144
-
145
- if (lastMeasuredItemOffset >= offset) {
146
- // If we've already measured items within this range just use a binary search as it's faster.
147
- return findNearestItemBinarySearch(
148
- itemType,
149
- props,
150
- instanceProps,
151
- lastMeasuredIndex,
152
- 0,
153
- offset
154
- );
155
- } else {
156
- // If we haven't yet measured this high, fallback to an exponential search with an inner binary search.
157
- // The exponential search avoids pre-computing sizes for the full set of items as a binary search would.
158
- // The overall complexity for this approach is O(log n).
159
- return findNearestItemExponentialSearch(
160
- itemType,
161
- props,
162
- instanceProps,
163
- Math.max(0, lastMeasuredIndex),
164
- offset
165
- );
166
- }
167
- };
168
-
169
- const findNearestItemBinarySearch = (
170
- itemType: ItemType,
171
- props: Props<any>,
172
- instanceProps: InstanceProps,
173
- high: number,
174
- low: number,
175
- offset: number
176
- ): number => {
177
- while (low <= high) {
178
- const middle = low + Math.floor((high - low) / 2);
179
- const currentOffset = getItemMetadata(
180
- itemType,
181
- props,
182
- middle,
183
- instanceProps
184
- ).offset;
185
-
186
- if (currentOffset === offset) {
187
- return middle;
188
- } else if (currentOffset < offset) {
189
- low = middle + 1;
190
- } else if (currentOffset > offset) {
191
- high = middle - 1;
192
- }
193
- }
194
-
195
- if (low > 0) {
196
- return low - 1;
197
- } else {
198
- return 0;
199
- }
200
- };
201
-
202
- const findNearestItemExponentialSearch = (
203
- itemType: ItemType,
204
- props: Props<any>,
205
- instanceProps: InstanceProps,
206
- index: number,
207
- offset: number
208
- ): number => {
209
- const itemCount = itemType === 'column' ? props.columnCount : props.rowCount;
210
- let interval = 1;
211
-
212
- while (
213
- index < itemCount &&
214
- getItemMetadata(itemType, props, index, instanceProps).offset < offset
215
- ) {
216
- index += interval;
217
- interval *= 2;
218
- }
219
-
220
- return findNearestItemBinarySearch(
221
- itemType,
222
- props,
223
- instanceProps,
224
- Math.min(index, itemCount - 1),
225
- Math.floor(index / 2),
226
- offset
227
- );
228
- };
229
-
230
- const getOffsetForIndexAndAlignment = (
231
- itemType: ItemType,
232
- props: Props<any>,
233
- index: number,
234
- align: ScrollToAlign,
235
- scrollOffset: number,
236
- instanceProps: InstanceProps,
237
- scrollbarSize: number
238
- ): number => {
239
- const size = itemType === 'column' ? props.width : props.height;
240
- const itemMetadata = getItemMetadata(itemType, props, index, instanceProps);
241
-
242
- // Get estimated total size after ItemMetadata is computed,
243
- // To ensure it reflects actual measurements instead of just estimates.
244
- const estimatedTotalSize =
245
- itemType === 'column'
246
- ? getEstimatedTotalWidth(props, instanceProps)
247
- : getEstimatedTotalHeight(props, instanceProps);
248
-
249
- const maxOffset = Math.max(
250
- 0,
251
- Math.min(estimatedTotalSize - size, itemMetadata.offset)
252
- );
253
- const minOffset = Math.max(
254
- 0,
255
- itemMetadata.offset - size + scrollbarSize + itemMetadata.size
256
- );
257
-
258
- if (align === 'smart') {
259
- if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
260
- align = 'auto';
261
- } else {
262
- align = 'center';
263
- }
264
- }
265
-
266
- switch (align) {
267
- case 'start':
268
- return maxOffset;
269
- case 'end':
270
- return minOffset;
271
- case 'center':
272
- return Math.round(minOffset + (maxOffset - minOffset) / 2);
273
- case 'auto':
274
- default:
275
- if (scrollOffset >= minOffset && scrollOffset <= maxOffset) {
276
- return scrollOffset;
277
- } else if (minOffset > maxOffset) {
278
- // Because we only take into account the scrollbar size when calculating minOffset
279
- // this value can be larger than maxOffset when at the end of the list
280
- return minOffset;
281
- } else if (scrollOffset < minOffset) {
282
- return minOffset;
283
- } else {
284
- return maxOffset;
285
- }
286
- }
287
- };
288
-
289
- const VariableSizeGrid = createGridComponent({
290
- getColumnOffset: (
291
- props: Props<any>,
292
- index: number,
293
- instanceProps: InstanceProps
294
- ): number => getItemMetadata('column', props, index, instanceProps).offset,
295
-
296
- getColumnStartIndexForOffset: (
297
- props: Props<any>,
298
- scrollLeft: number,
299
- instanceProps: InstanceProps
300
- ): number => findNearestItem('column', props, instanceProps, scrollLeft),
301
-
302
- getColumnStopIndexForStartIndex: (
303
- props: Props<any>,
304
- startIndex: number,
305
- scrollLeft: number,
306
- instanceProps: InstanceProps
307
- ): number => {
308
- const { columnCount, width } = props;
309
-
310
- const itemMetadata = getItemMetadata(
311
- 'column',
312
- props,
313
- startIndex,
314
- instanceProps
315
- );
316
- const maxOffset = scrollLeft + width;
317
-
318
- let offset = itemMetadata.offset + itemMetadata.size;
319
- let stopIndex = startIndex;
320
-
321
- while (stopIndex < columnCount - 1 && offset < maxOffset) {
322
- stopIndex++;
323
- offset += getItemMetadata('column', props, stopIndex, instanceProps).size;
324
- }
325
-
326
- return stopIndex;
327
- },
328
-
329
- getColumnWidth: (
330
- props: Props<any>,
331
- index: number,
332
- instanceProps: InstanceProps
333
- ): number => instanceProps.columnMetadataMap[index].size,
334
-
335
- getEstimatedTotalHeight,
336
- getEstimatedTotalWidth,
337
-
338
- getOffsetForColumnAndAlignment: (
339
- props: Props<any>,
340
- index: number,
341
- align: ScrollToAlign,
342
- scrollOffset: number,
343
- instanceProps: InstanceProps,
344
- scrollbarSize: number
345
- ): number =>
346
- getOffsetForIndexAndAlignment(
347
- 'column',
348
- props,
349
- index,
350
- align,
351
- scrollOffset,
352
- instanceProps,
353
- scrollbarSize
354
- ),
355
-
356
- getOffsetForRowAndAlignment: (
357
- props: Props<any>,
358
- index: number,
359
- align: ScrollToAlign,
360
- scrollOffset: number,
361
- instanceProps: InstanceProps,
362
- scrollbarSize: number
363
- ): number =>
364
- getOffsetForIndexAndAlignment(
365
- 'row',
366
- props,
367
- index,
368
- align,
369
- scrollOffset,
370
- instanceProps,
371
- scrollbarSize
372
- ),
373
-
374
- getRowOffset: (
375
- props: Props<any>,
376
- index: number,
377
- instanceProps: InstanceProps
378
- ): number => getItemMetadata('row', props, index, instanceProps).offset,
379
-
380
- getRowHeight: (
381
- props: Props<any>,
382
- index: number,
383
- instanceProps: InstanceProps
384
- ): number => instanceProps.rowMetadataMap[index].size,
385
-
386
- getRowStartIndexForOffset: (
387
- props: Props<any>,
388
- scrollTop: number,
389
- instanceProps: InstanceProps
390
- ): number => findNearestItem('row', props, instanceProps, scrollTop),
391
-
392
- getRowStopIndexForStartIndex: (
393
- props: Props<any>,
394
- startIndex: number,
395
- scrollTop: number,
396
- instanceProps: InstanceProps
397
- ): number => {
398
- const { rowCount, height } = props;
399
-
400
- const itemMetadata = getItemMetadata(
401
- 'row',
402
- props,
403
- startIndex,
404
- instanceProps
405
- );
406
- const maxOffset = scrollTop + height;
407
-
408
- let offset = itemMetadata.offset + itemMetadata.size;
409
- let stopIndex = startIndex;
410
-
411
- while (stopIndex < rowCount - 1 && offset < maxOffset) {
412
- stopIndex++;
413
- offset += getItemMetadata('row', props, stopIndex, instanceProps).size;
414
- }
415
-
416
- return stopIndex;
417
- },
418
-
419
- initInstanceProps(props: Props<any>, instance: any): InstanceProps {
420
- const {
421
- estimatedColumnWidth,
422
- estimatedRowHeight,
423
- } = ((props: any): VariableSizeProps);
424
-
425
- const instanceProps = {
426
- columnMetadataMap: {},
427
- estimatedColumnWidth: estimatedColumnWidth || DEFAULT_ESTIMATED_ITEM_SIZE,
428
- estimatedRowHeight: estimatedRowHeight || DEFAULT_ESTIMATED_ITEM_SIZE,
429
- lastMeasuredColumnIndex: -1,
430
- lastMeasuredRowIndex: -1,
431
- rowMetadataMap: {},
432
- };
433
-
434
- instance.resetAfterColumnIndex = (
435
- columnIndex: number,
436
- shouldForceUpdate?: boolean = true
437
- ) => {
438
- instance.resetAfterIndices({ columnIndex, shouldForceUpdate });
439
- };
440
-
441
- instance.resetAfterRowIndex = (
442
- rowIndex: number,
443
- shouldForceUpdate?: boolean = true
444
- ) => {
445
- instance.resetAfterIndices({ rowIndex, shouldForceUpdate });
446
- };
447
-
448
- instance.resetAfterIndices = ({
449
- columnIndex,
450
- rowIndex,
451
- shouldForceUpdate = true,
452
- }: {
453
- columnIndex?: number,
454
- rowIndex?: number,
455
- shouldForceUpdate: boolean,
456
- }) => {
457
- if (typeof columnIndex === 'number') {
458
- instanceProps.lastMeasuredColumnIndex = Math.min(
459
- instanceProps.lastMeasuredColumnIndex,
460
- columnIndex - 1
461
- );
462
- }
463
- if (typeof rowIndex === 'number') {
464
- instanceProps.lastMeasuredRowIndex = Math.min(
465
- instanceProps.lastMeasuredRowIndex,
466
- rowIndex - 1
467
- );
468
- }
469
-
470
- // We could potentially optimize further by only evicting styles after this index,
471
- // But since styles are only cached while scrolling is in progress-
472
- // It seems an unnecessary optimization.
473
- // It's unlikely that resetAfterIndex() will be called while a user is scrolling.
474
- instance._getItemStyleCache(-1);
475
-
476
- if (shouldForceUpdate) {
477
- instance.forceUpdate();
478
- }
479
- };
480
-
481
- return instanceProps;
482
- },
483
-
484
- shouldResetStyleCacheOnItemSizeChange: false,
485
-
486
- validateProps: ({ columnWidth, rowHeight }: Props<any>): void => {
487
- if (process.env.NODE_ENV !== 'production') {
488
- if (typeof columnWidth !== 'function') {
489
- throw Error(
490
- 'An invalid "columnWidth" prop has been specified. ' +
491
- 'Value should be a function. ' +
492
- `"${
493
- columnWidth === null ? 'null' : typeof columnWidth
494
- }" was specified.`
495
- );
496
- } else if (typeof rowHeight !== 'function') {
497
- throw Error(
498
- 'An invalid "rowHeight" prop has been specified. ' +
499
- 'Value should be a function. ' +
500
- `"${rowHeight === null ? 'null' : typeof rowHeight}" was specified.`
501
- );
502
- }
503
- }
504
- },
505
- });
506
-
507
- export default VariableSizeGrid;