@legendapp/list 2.0.0-beta.4 → 2.0.0-beta.6

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 (4) hide show
  1. package/.DS_Store +0 -0
  2. package/index.js +70 -57
  3. package/index.mjs +70 -57
  4. package/package.json +1 -1
package/.DS_Store ADDED
Binary file
package/index.js CHANGED
@@ -915,7 +915,7 @@ function calculateOffsetForIndex(ctx, state, index) {
915
915
  }
916
916
 
917
917
  // src/utils/getItemSize.ts
918
- function getItemSize(state, key, index, data, useAverageSize, defaultAverageSize) {
918
+ function getItemSize(state, key, index, data, useAverageSize) {
919
919
  var _a, _b;
920
920
  const {
921
921
  sizesKnown,
@@ -937,13 +937,9 @@ function getItemSize(state, key, index, data, useAverageSize, defaultAverageSize
937
937
  }
938
938
  }
939
939
  if (size === void 0 && useAverageSize && sizeKnown === void 0 && !scrollingTo) {
940
- if (itemType === "") {
941
- size = defaultAverageSize;
942
- } else {
943
- const averageSizeForType = (_b = averageSizes[itemType]) == null ? void 0 : _b.avg;
944
- if (averageSizeForType !== void 0) {
945
- size = roundSize(averageSizeForType);
946
- }
940
+ const averageSizeForType = (_b = averageSizes[itemType]) == null ? void 0 : _b.avg;
941
+ if (averageSizeForType !== void 0) {
942
+ size = roundSize(averageSizeForType);
947
943
  }
948
944
  }
949
945
  if (size === void 0) {
@@ -1194,9 +1190,8 @@ function updateSnapToOffsets(ctx, state) {
1194
1190
 
1195
1191
  // src/core/updateAllPositions.ts
1196
1192
  function updateAllPositions(ctx, state, dataChanged, startIndex = 0) {
1197
- var _a, _b, _c, _d, _e, _f, _g;
1193
+ var _a, _b, _c, _d, _e, _f;
1198
1194
  const {
1199
- averageSizes,
1200
1195
  columns,
1201
1196
  indexByKey,
1202
1197
  positions,
@@ -1208,33 +1203,28 @@ function updateAllPositions(ctx, state, dataChanged, startIndex = 0) {
1208
1203
  const numColumns = peek$(ctx, "numColumns");
1209
1204
  const indexByKeyForChecking = __DEV__ ? /* @__PURE__ */ new Map() : void 0;
1210
1205
  const useAverageSize = enableAverages && !getEstimatedItemSize;
1211
- const itemType = "";
1212
- let averageSize = (_a = averageSizes[itemType]) == null ? void 0 : _a.avg;
1213
- if (averageSize !== void 0) {
1214
- averageSize = roundSize(averageSize);
1215
- }
1216
1206
  let currentRowTop = 0;
1217
1207
  let column = 1;
1218
1208
  let maxSizeInRow = 0;
1219
1209
  const hasColumns = numColumns > 1;
1220
1210
  if (startIndex > 0) {
1221
1211
  const prevIndex = startIndex - 1;
1222
- const prevId = (_b = idCache.get(prevIndex)) != null ? _b : getId(state, prevIndex);
1223
- const prevPosition = (_c = positions.get(prevId)) != null ? _c : 0;
1212
+ const prevId = (_a = idCache.get(prevIndex)) != null ? _a : getId(state, prevIndex);
1213
+ const prevPosition = (_b = positions.get(prevId)) != null ? _b : 0;
1224
1214
  if (hasColumns) {
1225
- const prevColumn = (_d = columns.get(prevId)) != null ? _d : 1;
1215
+ const prevColumn = (_c = columns.get(prevId)) != null ? _c : 1;
1226
1216
  currentRowTop = prevPosition;
1227
1217
  column = prevColumn % numColumns + 1;
1228
1218
  } else {
1229
- const prevSize = (_e = sizesKnown.get(prevId)) != null ? _e : getItemSize(state, prevId, prevIndex, data[prevIndex], useAverageSize, averageSize);
1219
+ const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(state, prevId, prevIndex, data[prevIndex], useAverageSize);
1230
1220
  currentRowTop = prevPosition + prevSize;
1231
1221
  }
1232
1222
  }
1233
1223
  const needsIndexByKey = dataChanged || indexByKey.size === 0;
1234
1224
  const dataLength = data.length;
1235
1225
  for (let i = startIndex; i < dataLength; i++) {
1236
- const id = (_f = idCache.get(i)) != null ? _f : getId(state, i);
1237
- const size = (_g = sizesKnown.get(id)) != null ? _g : getItemSize(state, id, i, data[i], useAverageSize, averageSize);
1226
+ const id = (_e = idCache.get(i)) != null ? _e : getId(state, i);
1227
+ const size = (_f = sizesKnown.get(id)) != null ? _f : getItemSize(state, id, i, data[i], useAverageSize);
1238
1228
  if (__DEV__ && needsIndexByKey) {
1239
1229
  if (indexByKeyForChecking.has(id)) {
1240
1230
  console.error(
@@ -1466,6 +1456,7 @@ function maybeUpdateViewabilityCallback(ctx, configId, containerId, viewToken) {
1466
1456
  const cb = ctx.mapViewabilityCallbacks.get(key);
1467
1457
  cb == null ? void 0 : cb(viewToken);
1468
1458
  }
1459
+ var batchedUpdates = reactNative.unstable_batchedUpdates || ((callback) => callback());
1469
1460
 
1470
1461
  // src/utils/checkAllSizesKnown.ts
1471
1462
  function checkAllSizesKnown(state) {
@@ -1809,7 +1800,7 @@ function handleStickyRecycling(ctx, state, stickyArray, scroll, scrollBuffer, pe
1809
1800
  }
1810
1801
  }
1811
1802
  function calculateItemsInView(ctx, state, params = {}) {
1812
- reactNative.unstable_batchedUpdates(() => {
1803
+ batchedUpdates(() => {
1813
1804
  var _a, _b, _c, _d, _e, _f, _g, _h;
1814
1805
  const {
1815
1806
  columns,
@@ -2115,10 +2106,30 @@ function doInitialAllocateContainers(ctx, state) {
2115
2106
  var _a;
2116
2107
  const {
2117
2108
  scrollLength,
2118
- props: { data, getEstimatedItemSize, getItemType, scrollBuffer, numColumns, estimatedItemSize }
2109
+ props: {
2110
+ data,
2111
+ getEstimatedItemSize,
2112
+ getFixedItemSize,
2113
+ getItemType,
2114
+ scrollBuffer,
2115
+ numColumns,
2116
+ estimatedItemSize
2117
+ }
2119
2118
  } = state;
2120
- if (scrollLength > 0 && data.length > 0 && !peek$(ctx, "numContainers")) {
2121
- const averageItemSize = getEstimatedItemSize ? getEstimatedItemSize(0, data[0], getItemType ? (_a = getItemType(data[0], 0)) != null ? _a : "" : "") : estimatedItemSize;
2119
+ const hasContainers = peek$(ctx, "numContainers");
2120
+ if (scrollLength > 0 && data.length > 0 && !hasContainers) {
2121
+ let averageItemSize;
2122
+ const fn = getFixedItemSize || getEstimatedItemSize;
2123
+ if (fn) {
2124
+ let totalSize = 0;
2125
+ const num = Math.min(20, data.length);
2126
+ for (let i = 0; i < num; i++) {
2127
+ totalSize += fn(0, data[0], getItemType ? (_a = getItemType(data[0], 0)) != null ? _a : "" : "");
2128
+ }
2129
+ averageItemSize = totalSize / num;
2130
+ } else {
2131
+ averageItemSize = estimatedItemSize;
2132
+ }
2122
2133
  const numContainers = Math.ceil((scrollLength + scrollBuffer * 2) / averageItemSize * numColumns);
2123
2134
  for (let i = 0; i < numContainers; i++) {
2124
2135
  set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
@@ -2126,13 +2137,13 @@ function doInitialAllocateContainers(ctx, state) {
2126
2137
  }
2127
2138
  set$(ctx, "numContainers", numContainers);
2128
2139
  set$(ctx, "numContainersPooled", numContainers * state.props.initialContainerPoolRatio);
2129
- if (!IsNewArchitecture) {
2140
+ if (!IsNewArchitecture || state.lastLayout) {
2130
2141
  if (state.props.initialScroll) {
2131
2142
  requestAnimationFrame(() => {
2132
- calculateItemsInView(ctx, state);
2143
+ calculateItemsInView(ctx, state, { dataChanged: true });
2133
2144
  });
2134
2145
  } else {
2135
- calculateItemsInView(ctx, state);
2146
+ calculateItemsInView(ctx, state, { dataChanged: true });
2136
2147
  }
2137
2148
  }
2138
2149
  return true;
@@ -2204,35 +2215,37 @@ function handleLayout(ctx, state, layout, setCanRender) {
2204
2215
  const otherAxisSize = layout[state.props.horizontal ? "height" : "width"];
2205
2216
  const needsCalculate = !state.lastLayout || scrollLength > state.scrollLength || state.lastLayout.x !== layout.x || state.lastLayout.y !== layout.y;
2206
2217
  state.lastLayout = layout;
2207
- const didChange = scrollLength !== state.scrollLength;
2208
2218
  const prevOtherAxisSize = state.otherAxisSize;
2209
- state.scrollLength = scrollLength;
2210
- state.otherAxisSize = otherAxisSize;
2211
- state.lastBatchingAction = Date.now();
2212
- state.scrollForNextCalculateItemsInView = void 0;
2213
- doInitialAllocateContainers(ctx, state);
2214
- if (needsCalculate) {
2215
- calculateItemsInView(ctx, state, { doMVCP: true });
2216
- }
2217
- if (didChange || otherAxisSize !== prevOtherAxisSize) {
2218
- set$(ctx, "scrollSize", { height: layout.height, width: layout.width });
2219
- }
2220
- if (maintainScrollAtEnd === true || maintainScrollAtEnd.onLayout) {
2221
- doMaintainScrollAtEnd(ctx, state, false);
2222
- }
2223
- updateAlignItemsPaddingTop(ctx, state);
2224
- checkAtBottom(ctx, state);
2225
- checkAtTop(state);
2226
- if (state) {
2227
- state.needsOtherAxisSize = otherAxisSize - (state.props.stylePaddingTop || 0) < 10;
2228
- }
2229
- if (__DEV__ && scrollLength === 0) {
2230
- warnDevOnce(
2231
- "height0",
2232
- `List ${state.props.horizontal ? "width" : "height"} is 0. You may need to set a style or \`flex: \` for the list, because children are absolutely positioned.`
2233
- );
2219
+ const didChange = scrollLength !== state.scrollLength || otherAxisSize !== prevOtherAxisSize;
2220
+ if (didChange) {
2221
+ state.scrollLength = scrollLength;
2222
+ state.otherAxisSize = otherAxisSize;
2223
+ state.lastBatchingAction = Date.now();
2224
+ state.scrollForNextCalculateItemsInView = void 0;
2225
+ doInitialAllocateContainers(ctx, state);
2226
+ if (needsCalculate) {
2227
+ calculateItemsInView(ctx, state, { doMVCP: true });
2228
+ }
2229
+ if (didChange || otherAxisSize !== prevOtherAxisSize) {
2230
+ set$(ctx, "scrollSize", { height: layout.height, width: layout.width });
2231
+ }
2232
+ if (maintainScrollAtEnd === true || maintainScrollAtEnd.onLayout) {
2233
+ doMaintainScrollAtEnd(ctx, state, false);
2234
+ }
2235
+ updateAlignItemsPaddingTop(ctx, state);
2236
+ checkAtBottom(ctx, state);
2237
+ checkAtTop(state);
2238
+ if (state) {
2239
+ state.needsOtherAxisSize = otherAxisSize - (state.props.stylePaddingTop || 0) < 10;
2240
+ }
2241
+ if (__DEV__ && scrollLength === 0) {
2242
+ warnDevOnce(
2243
+ "height0",
2244
+ `List ${state.props.horizontal ? "width" : "height"} is 0. You may need to set a style or \`flex: \` for the list, because children are absolutely positioned.`
2245
+ );
2246
+ }
2247
+ setCanRender(true);
2234
2248
  }
2235
- setCanRender(true);
2236
2249
  }
2237
2250
 
2238
2251
  // src/core/onScroll.ts
@@ -2425,7 +2438,7 @@ function updateOneItemSize(state, itemKey, sizeObj) {
2425
2438
  const prevSize = getItemSize(state, itemKey, index, data);
2426
2439
  const size = Math.floor((horizontal ? sizeObj.width : sizeObj.height) * 8) / 8;
2427
2440
  sizesKnown.set(itemKey, size);
2428
- if (!getEstimatedItemSize && !getFixedItemSize) {
2441
+ if (!getEstimatedItemSize && !getFixedItemSize && size > 0) {
2429
2442
  const itemType = getItemType ? (_a = getItemType(data[index], index)) != null ? _a : "" : "";
2430
2443
  let averages = averageSizes[itemType];
2431
2444
  if (!averages) {
@@ -2830,7 +2843,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2830
2843
  }
2831
2844
  }, [snapToIndices]);
2832
2845
  React3.useLayoutEffect(() => {
2833
- const didAllocateContainers = doInitialAllocateContainersCallback();
2846
+ const didAllocateContainers = dataProp.length > 0 && doInitialAllocateContainersCallback();
2834
2847
  if (!didAllocateContainers) {
2835
2848
  checkResetContainers(
2836
2849
  /*isFirst*/
package/index.mjs CHANGED
@@ -894,7 +894,7 @@ function calculateOffsetForIndex(ctx, state, index) {
894
894
  }
895
895
 
896
896
  // src/utils/getItemSize.ts
897
- function getItemSize(state, key, index, data, useAverageSize, defaultAverageSize) {
897
+ function getItemSize(state, key, index, data, useAverageSize) {
898
898
  var _a, _b;
899
899
  const {
900
900
  sizesKnown,
@@ -916,13 +916,9 @@ function getItemSize(state, key, index, data, useAverageSize, defaultAverageSize
916
916
  }
917
917
  }
918
918
  if (size === void 0 && useAverageSize && sizeKnown === void 0 && !scrollingTo) {
919
- if (itemType === "") {
920
- size = defaultAverageSize;
921
- } else {
922
- const averageSizeForType = (_b = averageSizes[itemType]) == null ? void 0 : _b.avg;
923
- if (averageSizeForType !== void 0) {
924
- size = roundSize(averageSizeForType);
925
- }
919
+ const averageSizeForType = (_b = averageSizes[itemType]) == null ? void 0 : _b.avg;
920
+ if (averageSizeForType !== void 0) {
921
+ size = roundSize(averageSizeForType);
926
922
  }
927
923
  }
928
924
  if (size === void 0) {
@@ -1173,9 +1169,8 @@ function updateSnapToOffsets(ctx, state) {
1173
1169
 
1174
1170
  // src/core/updateAllPositions.ts
1175
1171
  function updateAllPositions(ctx, state, dataChanged, startIndex = 0) {
1176
- var _a, _b, _c, _d, _e, _f, _g;
1172
+ var _a, _b, _c, _d, _e, _f;
1177
1173
  const {
1178
- averageSizes,
1179
1174
  columns,
1180
1175
  indexByKey,
1181
1176
  positions,
@@ -1187,33 +1182,28 @@ function updateAllPositions(ctx, state, dataChanged, startIndex = 0) {
1187
1182
  const numColumns = peek$(ctx, "numColumns");
1188
1183
  const indexByKeyForChecking = __DEV__ ? /* @__PURE__ */ new Map() : void 0;
1189
1184
  const useAverageSize = enableAverages && !getEstimatedItemSize;
1190
- const itemType = "";
1191
- let averageSize = (_a = averageSizes[itemType]) == null ? void 0 : _a.avg;
1192
- if (averageSize !== void 0) {
1193
- averageSize = roundSize(averageSize);
1194
- }
1195
1185
  let currentRowTop = 0;
1196
1186
  let column = 1;
1197
1187
  let maxSizeInRow = 0;
1198
1188
  const hasColumns = numColumns > 1;
1199
1189
  if (startIndex > 0) {
1200
1190
  const prevIndex = startIndex - 1;
1201
- const prevId = (_b = idCache.get(prevIndex)) != null ? _b : getId(state, prevIndex);
1202
- const prevPosition = (_c = positions.get(prevId)) != null ? _c : 0;
1191
+ const prevId = (_a = idCache.get(prevIndex)) != null ? _a : getId(state, prevIndex);
1192
+ const prevPosition = (_b = positions.get(prevId)) != null ? _b : 0;
1203
1193
  if (hasColumns) {
1204
- const prevColumn = (_d = columns.get(prevId)) != null ? _d : 1;
1194
+ const prevColumn = (_c = columns.get(prevId)) != null ? _c : 1;
1205
1195
  currentRowTop = prevPosition;
1206
1196
  column = prevColumn % numColumns + 1;
1207
1197
  } else {
1208
- const prevSize = (_e = sizesKnown.get(prevId)) != null ? _e : getItemSize(state, prevId, prevIndex, data[prevIndex], useAverageSize, averageSize);
1198
+ const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(state, prevId, prevIndex, data[prevIndex], useAverageSize);
1209
1199
  currentRowTop = prevPosition + prevSize;
1210
1200
  }
1211
1201
  }
1212
1202
  const needsIndexByKey = dataChanged || indexByKey.size === 0;
1213
1203
  const dataLength = data.length;
1214
1204
  for (let i = startIndex; i < dataLength; i++) {
1215
- const id = (_f = idCache.get(i)) != null ? _f : getId(state, i);
1216
- const size = (_g = sizesKnown.get(id)) != null ? _g : getItemSize(state, id, i, data[i], useAverageSize, averageSize);
1205
+ const id = (_e = idCache.get(i)) != null ? _e : getId(state, i);
1206
+ const size = (_f = sizesKnown.get(id)) != null ? _f : getItemSize(state, id, i, data[i], useAverageSize);
1217
1207
  if (__DEV__ && needsIndexByKey) {
1218
1208
  if (indexByKeyForChecking.has(id)) {
1219
1209
  console.error(
@@ -1445,6 +1435,7 @@ function maybeUpdateViewabilityCallback(ctx, configId, containerId, viewToken) {
1445
1435
  const cb = ctx.mapViewabilityCallbacks.get(key);
1446
1436
  cb == null ? void 0 : cb(viewToken);
1447
1437
  }
1438
+ var batchedUpdates = unstable_batchedUpdates || ((callback) => callback());
1448
1439
 
1449
1440
  // src/utils/checkAllSizesKnown.ts
1450
1441
  function checkAllSizesKnown(state) {
@@ -1788,7 +1779,7 @@ function handleStickyRecycling(ctx, state, stickyArray, scroll, scrollBuffer, pe
1788
1779
  }
1789
1780
  }
1790
1781
  function calculateItemsInView(ctx, state, params = {}) {
1791
- unstable_batchedUpdates(() => {
1782
+ batchedUpdates(() => {
1792
1783
  var _a, _b, _c, _d, _e, _f, _g, _h;
1793
1784
  const {
1794
1785
  columns,
@@ -2094,10 +2085,30 @@ function doInitialAllocateContainers(ctx, state) {
2094
2085
  var _a;
2095
2086
  const {
2096
2087
  scrollLength,
2097
- props: { data, getEstimatedItemSize, getItemType, scrollBuffer, numColumns, estimatedItemSize }
2088
+ props: {
2089
+ data,
2090
+ getEstimatedItemSize,
2091
+ getFixedItemSize,
2092
+ getItemType,
2093
+ scrollBuffer,
2094
+ numColumns,
2095
+ estimatedItemSize
2096
+ }
2098
2097
  } = state;
2099
- if (scrollLength > 0 && data.length > 0 && !peek$(ctx, "numContainers")) {
2100
- const averageItemSize = getEstimatedItemSize ? getEstimatedItemSize(0, data[0], getItemType ? (_a = getItemType(data[0], 0)) != null ? _a : "" : "") : estimatedItemSize;
2098
+ const hasContainers = peek$(ctx, "numContainers");
2099
+ if (scrollLength > 0 && data.length > 0 && !hasContainers) {
2100
+ let averageItemSize;
2101
+ const fn = getFixedItemSize || getEstimatedItemSize;
2102
+ if (fn) {
2103
+ let totalSize = 0;
2104
+ const num = Math.min(20, data.length);
2105
+ for (let i = 0; i < num; i++) {
2106
+ totalSize += fn(0, data[0], getItemType ? (_a = getItemType(data[0], 0)) != null ? _a : "" : "");
2107
+ }
2108
+ averageItemSize = totalSize / num;
2109
+ } else {
2110
+ averageItemSize = estimatedItemSize;
2111
+ }
2101
2112
  const numContainers = Math.ceil((scrollLength + scrollBuffer * 2) / averageItemSize * numColumns);
2102
2113
  for (let i = 0; i < numContainers; i++) {
2103
2114
  set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
@@ -2105,13 +2116,13 @@ function doInitialAllocateContainers(ctx, state) {
2105
2116
  }
2106
2117
  set$(ctx, "numContainers", numContainers);
2107
2118
  set$(ctx, "numContainersPooled", numContainers * state.props.initialContainerPoolRatio);
2108
- if (!IsNewArchitecture) {
2119
+ if (!IsNewArchitecture || state.lastLayout) {
2109
2120
  if (state.props.initialScroll) {
2110
2121
  requestAnimationFrame(() => {
2111
- calculateItemsInView(ctx, state);
2122
+ calculateItemsInView(ctx, state, { dataChanged: true });
2112
2123
  });
2113
2124
  } else {
2114
- calculateItemsInView(ctx, state);
2125
+ calculateItemsInView(ctx, state, { dataChanged: true });
2115
2126
  }
2116
2127
  }
2117
2128
  return true;
@@ -2183,35 +2194,37 @@ function handleLayout(ctx, state, layout, setCanRender) {
2183
2194
  const otherAxisSize = layout[state.props.horizontal ? "height" : "width"];
2184
2195
  const needsCalculate = !state.lastLayout || scrollLength > state.scrollLength || state.lastLayout.x !== layout.x || state.lastLayout.y !== layout.y;
2185
2196
  state.lastLayout = layout;
2186
- const didChange = scrollLength !== state.scrollLength;
2187
2197
  const prevOtherAxisSize = state.otherAxisSize;
2188
- state.scrollLength = scrollLength;
2189
- state.otherAxisSize = otherAxisSize;
2190
- state.lastBatchingAction = Date.now();
2191
- state.scrollForNextCalculateItemsInView = void 0;
2192
- doInitialAllocateContainers(ctx, state);
2193
- if (needsCalculate) {
2194
- calculateItemsInView(ctx, state, { doMVCP: true });
2195
- }
2196
- if (didChange || otherAxisSize !== prevOtherAxisSize) {
2197
- set$(ctx, "scrollSize", { height: layout.height, width: layout.width });
2198
- }
2199
- if (maintainScrollAtEnd === true || maintainScrollAtEnd.onLayout) {
2200
- doMaintainScrollAtEnd(ctx, state, false);
2201
- }
2202
- updateAlignItemsPaddingTop(ctx, state);
2203
- checkAtBottom(ctx, state);
2204
- checkAtTop(state);
2205
- if (state) {
2206
- state.needsOtherAxisSize = otherAxisSize - (state.props.stylePaddingTop || 0) < 10;
2207
- }
2208
- if (__DEV__ && scrollLength === 0) {
2209
- warnDevOnce(
2210
- "height0",
2211
- `List ${state.props.horizontal ? "width" : "height"} is 0. You may need to set a style or \`flex: \` for the list, because children are absolutely positioned.`
2212
- );
2198
+ const didChange = scrollLength !== state.scrollLength || otherAxisSize !== prevOtherAxisSize;
2199
+ if (didChange) {
2200
+ state.scrollLength = scrollLength;
2201
+ state.otherAxisSize = otherAxisSize;
2202
+ state.lastBatchingAction = Date.now();
2203
+ state.scrollForNextCalculateItemsInView = void 0;
2204
+ doInitialAllocateContainers(ctx, state);
2205
+ if (needsCalculate) {
2206
+ calculateItemsInView(ctx, state, { doMVCP: true });
2207
+ }
2208
+ if (didChange || otherAxisSize !== prevOtherAxisSize) {
2209
+ set$(ctx, "scrollSize", { height: layout.height, width: layout.width });
2210
+ }
2211
+ if (maintainScrollAtEnd === true || maintainScrollAtEnd.onLayout) {
2212
+ doMaintainScrollAtEnd(ctx, state, false);
2213
+ }
2214
+ updateAlignItemsPaddingTop(ctx, state);
2215
+ checkAtBottom(ctx, state);
2216
+ checkAtTop(state);
2217
+ if (state) {
2218
+ state.needsOtherAxisSize = otherAxisSize - (state.props.stylePaddingTop || 0) < 10;
2219
+ }
2220
+ if (__DEV__ && scrollLength === 0) {
2221
+ warnDevOnce(
2222
+ "height0",
2223
+ `List ${state.props.horizontal ? "width" : "height"} is 0. You may need to set a style or \`flex: \` for the list, because children are absolutely positioned.`
2224
+ );
2225
+ }
2226
+ setCanRender(true);
2213
2227
  }
2214
- setCanRender(true);
2215
2228
  }
2216
2229
 
2217
2230
  // src/core/onScroll.ts
@@ -2404,7 +2417,7 @@ function updateOneItemSize(state, itemKey, sizeObj) {
2404
2417
  const prevSize = getItemSize(state, itemKey, index, data);
2405
2418
  const size = Math.floor((horizontal ? sizeObj.width : sizeObj.height) * 8) / 8;
2406
2419
  sizesKnown.set(itemKey, size);
2407
- if (!getEstimatedItemSize && !getFixedItemSize) {
2420
+ if (!getEstimatedItemSize && !getFixedItemSize && size > 0) {
2408
2421
  const itemType = getItemType ? (_a = getItemType(data[index], index)) != null ? _a : "" : "";
2409
2422
  let averages = averageSizes[itemType];
2410
2423
  if (!averages) {
@@ -2809,7 +2822,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2809
2822
  }
2810
2823
  }, [snapToIndices]);
2811
2824
  useLayoutEffect(() => {
2812
- const didAllocateContainers = doInitialAllocateContainersCallback();
2825
+ const didAllocateContainers = dataProp.length > 0 && doInitialAllocateContainersCallback();
2813
2826
  if (!didAllocateContainers) {
2814
2827
  checkResetContainers(
2815
2828
  /*isFirst*/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "2.0.0-beta.4",
3
+ "version": "2.0.0-beta.6",
4
4
  "description": "Legend List is a drop-in replacement for FlatList with much better performance and supporting dynamically sized items.",
5
5
  "sideEffects": false,
6
6
  "private": false,