@legendapp/list 3.3.9 → 3.3.10

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 3.3.10
2
+
3
+ - Fix: Changing `dataKey` no longer loses the new dataset's initial scroll position when React retries a render.
4
+
1
5
  ## 3.3.9
2
6
 
3
7
  - Fix: Rows after an item that changes size stay in the correct positions while scrolling
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "3.3.9",
3
+ "version": "3.3.10",
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,
package/react-native.js CHANGED
@@ -7470,6 +7470,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7470
7470
  refState.current = ctx.state;
7471
7471
  }
7472
7472
  const state = refState.current;
7473
+ const handledDataChangeEpochRef = React2.useRef(state.dataChangeEpoch);
7474
+ const handledFreshDataTransitionEpochRef = React2.useRef(state.freshDataTransitionEpoch);
7473
7475
  const isFirstLocal = state.isFirst;
7474
7476
  const previousAdaptiveRender = state.props.adaptiveRender;
7475
7477
  const previousHideItemsUntilMeasured = state.props.hideItemsUntilMeasured;
@@ -7495,6 +7497,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7495
7497
  if (shouldResetFreshDataLayout) {
7496
7498
  state.freshDataTransitionEpoch += 1;
7497
7499
  }
7500
+ const dataChangeEpoch = state.dataChangeEpoch;
7501
+ const freshDataTransitionEpoch = state.freshDataTransitionEpoch;
7498
7502
  const throttledOnScroll = useThrottledOnScroll(onScrollProp != null ? onScrollProp : noopOnScroll, scrollEventThrottle != null ? scrollEventThrottle : 0);
7499
7503
  const throttleScrollFn = scrollEventThrottle && onScrollProp ? throttledOnScroll : onScrollProp;
7500
7504
  const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_q = state.props.anchoredEndSpace) == null ? void 0 : _q.anchorIndex) !== (anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
@@ -7622,7 +7626,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7622
7626
  useDevChecks(props);
7623
7627
  }
7624
7628
  React2.useLayoutEffect(() => {
7625
- if (shouldResetFreshDataLayout) {
7629
+ const didDataChange = handledDataChangeEpochRef.current !== dataChangeEpoch;
7630
+ const didStartFreshData = handledFreshDataTransitionEpochRef.current !== freshDataTransitionEpoch;
7631
+ handledDataChangeEpochRef.current = dataChangeEpoch;
7632
+ handledFreshDataTransitionEpochRef.current = freshDataTransitionEpoch;
7633
+ if (didStartFreshData) {
7626
7634
  resetInitialRenderState(ctx, {
7627
7635
  resetInitialScroll: !!initialScrollProp,
7628
7636
  resetLayout: true
@@ -7630,8 +7638,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7630
7638
  }
7631
7639
  handleInitialScrollDataChange(ctx, {
7632
7640
  dataLength: dataProp.length,
7633
- didDataChange: didDataChangeLocal,
7634
- didStartFreshData: shouldResetFreshDataLayout,
7641
+ didDataChange,
7642
+ didStartFreshData,
7635
7643
  initialScrollAtEnd,
7636
7644
  latestInitialScroll: initialScrollProp,
7637
7645
  latestInitialScrollSessionKind: initialScrollUsesOffsetOnly ? "offset" : "bootstrap",
@@ -7641,8 +7649,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7641
7649
  }, [
7642
7650
  dataProp.length,
7643
7651
  dataKey,
7644
- didDataChangeLocal,
7645
- shouldResetFreshDataLayout,
7652
+ dataChangeEpoch,
7653
+ freshDataTransitionEpoch,
7646
7654
  initialScrollAtEnd,
7647
7655
  stylePaddingEndState,
7648
7656
  usesBootstrapInitialScroll
package/react-native.mjs CHANGED
@@ -7449,6 +7449,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7449
7449
  refState.current = ctx.state;
7450
7450
  }
7451
7451
  const state = refState.current;
7452
+ const handledDataChangeEpochRef = useRef(state.dataChangeEpoch);
7453
+ const handledFreshDataTransitionEpochRef = useRef(state.freshDataTransitionEpoch);
7452
7454
  const isFirstLocal = state.isFirst;
7453
7455
  const previousAdaptiveRender = state.props.adaptiveRender;
7454
7456
  const previousHideItemsUntilMeasured = state.props.hideItemsUntilMeasured;
@@ -7474,6 +7476,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7474
7476
  if (shouldResetFreshDataLayout) {
7475
7477
  state.freshDataTransitionEpoch += 1;
7476
7478
  }
7479
+ const dataChangeEpoch = state.dataChangeEpoch;
7480
+ const freshDataTransitionEpoch = state.freshDataTransitionEpoch;
7477
7481
  const throttledOnScroll = useThrottledOnScroll(onScrollProp != null ? onScrollProp : noopOnScroll, scrollEventThrottle != null ? scrollEventThrottle : 0);
7478
7482
  const throttleScrollFn = scrollEventThrottle && onScrollProp ? throttledOnScroll : onScrollProp;
7479
7483
  const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_q = state.props.anchoredEndSpace) == null ? void 0 : _q.anchorIndex) !== (anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
@@ -7601,7 +7605,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7601
7605
  useDevChecks(props);
7602
7606
  }
7603
7607
  useLayoutEffect(() => {
7604
- if (shouldResetFreshDataLayout) {
7608
+ const didDataChange = handledDataChangeEpochRef.current !== dataChangeEpoch;
7609
+ const didStartFreshData = handledFreshDataTransitionEpochRef.current !== freshDataTransitionEpoch;
7610
+ handledDataChangeEpochRef.current = dataChangeEpoch;
7611
+ handledFreshDataTransitionEpochRef.current = freshDataTransitionEpoch;
7612
+ if (didStartFreshData) {
7605
7613
  resetInitialRenderState(ctx, {
7606
7614
  resetInitialScroll: !!initialScrollProp,
7607
7615
  resetLayout: true
@@ -7609,8 +7617,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7609
7617
  }
7610
7618
  handleInitialScrollDataChange(ctx, {
7611
7619
  dataLength: dataProp.length,
7612
- didDataChange: didDataChangeLocal,
7613
- didStartFreshData: shouldResetFreshDataLayout,
7620
+ didDataChange,
7621
+ didStartFreshData,
7614
7622
  initialScrollAtEnd,
7615
7623
  latestInitialScroll: initialScrollProp,
7616
7624
  latestInitialScrollSessionKind: initialScrollUsesOffsetOnly ? "offset" : "bootstrap",
@@ -7620,8 +7628,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7620
7628
  }, [
7621
7629
  dataProp.length,
7622
7630
  dataKey,
7623
- didDataChangeLocal,
7624
- shouldResetFreshDataLayout,
7631
+ dataChangeEpoch,
7632
+ freshDataTransitionEpoch,
7625
7633
  initialScrollAtEnd,
7626
7634
  stylePaddingEndState,
7627
7635
  usesBootstrapInitialScroll
@@ -8075,6 +8075,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8075
8075
  refState.current = ctx.state;
8076
8076
  }
8077
8077
  const state = refState.current;
8078
+ const handledDataChangeEpochRef = React3.useRef(state.dataChangeEpoch);
8079
+ const handledFreshDataTransitionEpochRef = React3.useRef(state.freshDataTransitionEpoch);
8078
8080
  const isFirstLocal = state.isFirst;
8079
8081
  const previousAdaptiveRender = state.props.adaptiveRender;
8080
8082
  const previousHideItemsUntilMeasured = state.props.hideItemsUntilMeasured;
@@ -8100,6 +8102,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8100
8102
  if (shouldResetFreshDataLayout) {
8101
8103
  state.freshDataTransitionEpoch += 1;
8102
8104
  }
8105
+ const dataChangeEpoch = state.dataChangeEpoch;
8106
+ const freshDataTransitionEpoch = state.freshDataTransitionEpoch;
8103
8107
  const throttledOnScroll = useThrottledOnScroll(onScrollProp != null ? onScrollProp : noopOnScroll, scrollEventThrottle != null ? scrollEventThrottle : 0);
8104
8108
  const throttleScrollFn = scrollEventThrottle && onScrollProp ? throttledOnScroll : onScrollProp;
8105
8109
  const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_q = state.props.anchoredEndSpace) == null ? void 0 : _q.anchorIndex) !== (anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
@@ -8222,7 +8226,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8222
8226
  useDevChecks(props);
8223
8227
  }
8224
8228
  React3.useLayoutEffect(() => {
8225
- if (shouldResetFreshDataLayout) {
8229
+ const didDataChange = handledDataChangeEpochRef.current !== dataChangeEpoch;
8230
+ const didStartFreshData = handledFreshDataTransitionEpochRef.current !== freshDataTransitionEpoch;
8231
+ handledDataChangeEpochRef.current = dataChangeEpoch;
8232
+ handledFreshDataTransitionEpochRef.current = freshDataTransitionEpoch;
8233
+ if (didStartFreshData) {
8226
8234
  resetInitialRenderState(ctx, {
8227
8235
  resetInitialScroll: !!initialScrollProp,
8228
8236
  resetLayout: true
@@ -8230,8 +8238,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8230
8238
  }
8231
8239
  handleInitialScrollDataChange(ctx, {
8232
8240
  dataLength: dataProp.length,
8233
- didDataChange: didDataChangeLocal,
8234
- didStartFreshData: shouldResetFreshDataLayout,
8241
+ didDataChange,
8242
+ didStartFreshData,
8235
8243
  initialScrollAtEnd,
8236
8244
  latestInitialScroll: initialScrollProp,
8237
8245
  latestInitialScrollSessionKind: initialScrollUsesOffsetOnly ? "offset" : "bootstrap",
@@ -8241,8 +8249,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8241
8249
  }, [
8242
8250
  dataProp.length,
8243
8251
  dataKey,
8244
- didDataChangeLocal,
8245
- shouldResetFreshDataLayout,
8252
+ dataChangeEpoch,
8253
+ freshDataTransitionEpoch,
8246
8254
  initialScrollAtEnd,
8247
8255
  stylePaddingEndState,
8248
8256
  usesBootstrapInitialScroll
@@ -8054,6 +8054,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8054
8054
  refState.current = ctx.state;
8055
8055
  }
8056
8056
  const state = refState.current;
8057
+ const handledDataChangeEpochRef = useRef(state.dataChangeEpoch);
8058
+ const handledFreshDataTransitionEpochRef = useRef(state.freshDataTransitionEpoch);
8057
8059
  const isFirstLocal = state.isFirst;
8058
8060
  const previousAdaptiveRender = state.props.adaptiveRender;
8059
8061
  const previousHideItemsUntilMeasured = state.props.hideItemsUntilMeasured;
@@ -8079,6 +8081,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8079
8081
  if (shouldResetFreshDataLayout) {
8080
8082
  state.freshDataTransitionEpoch += 1;
8081
8083
  }
8084
+ const dataChangeEpoch = state.dataChangeEpoch;
8085
+ const freshDataTransitionEpoch = state.freshDataTransitionEpoch;
8082
8086
  const throttledOnScroll = useThrottledOnScroll(onScrollProp != null ? onScrollProp : noopOnScroll, scrollEventThrottle != null ? scrollEventThrottle : 0);
8083
8087
  const throttleScrollFn = scrollEventThrottle && onScrollProp ? throttledOnScroll : onScrollProp;
8084
8088
  const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_q = state.props.anchoredEndSpace) == null ? void 0 : _q.anchorIndex) !== (anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
@@ -8201,7 +8205,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8201
8205
  useDevChecks(props);
8202
8206
  }
8203
8207
  useLayoutEffect(() => {
8204
- if (shouldResetFreshDataLayout) {
8208
+ const didDataChange = handledDataChangeEpochRef.current !== dataChangeEpoch;
8209
+ const didStartFreshData = handledFreshDataTransitionEpochRef.current !== freshDataTransitionEpoch;
8210
+ handledDataChangeEpochRef.current = dataChangeEpoch;
8211
+ handledFreshDataTransitionEpochRef.current = freshDataTransitionEpoch;
8212
+ if (didStartFreshData) {
8205
8213
  resetInitialRenderState(ctx, {
8206
8214
  resetInitialScroll: !!initialScrollProp,
8207
8215
  resetLayout: true
@@ -8209,8 +8217,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8209
8217
  }
8210
8218
  handleInitialScrollDataChange(ctx, {
8211
8219
  dataLength: dataProp.length,
8212
- didDataChange: didDataChangeLocal,
8213
- didStartFreshData: shouldResetFreshDataLayout,
8220
+ didDataChange,
8221
+ didStartFreshData,
8214
8222
  initialScrollAtEnd,
8215
8223
  latestInitialScroll: initialScrollProp,
8216
8224
  latestInitialScrollSessionKind: initialScrollUsesOffsetOnly ? "offset" : "bootstrap",
@@ -8220,8 +8228,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8220
8228
  }, [
8221
8229
  dataProp.length,
8222
8230
  dataKey,
8223
- didDataChangeLocal,
8224
- shouldResetFreshDataLayout,
8231
+ dataChangeEpoch,
8232
+ freshDataTransitionEpoch,
8225
8233
  initialScrollAtEnd,
8226
8234
  stylePaddingEndState,
8227
8235
  usesBootstrapInitialScroll
package/react.js CHANGED
@@ -8075,6 +8075,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8075
8075
  refState.current = ctx.state;
8076
8076
  }
8077
8077
  const state = refState.current;
8078
+ const handledDataChangeEpochRef = React3.useRef(state.dataChangeEpoch);
8079
+ const handledFreshDataTransitionEpochRef = React3.useRef(state.freshDataTransitionEpoch);
8078
8080
  const isFirstLocal = state.isFirst;
8079
8081
  const previousAdaptiveRender = state.props.adaptiveRender;
8080
8082
  const previousHideItemsUntilMeasured = state.props.hideItemsUntilMeasured;
@@ -8100,6 +8102,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8100
8102
  if (shouldResetFreshDataLayout) {
8101
8103
  state.freshDataTransitionEpoch += 1;
8102
8104
  }
8105
+ const dataChangeEpoch = state.dataChangeEpoch;
8106
+ const freshDataTransitionEpoch = state.freshDataTransitionEpoch;
8103
8107
  const throttledOnScroll = useThrottledOnScroll(onScrollProp != null ? onScrollProp : noopOnScroll, scrollEventThrottle != null ? scrollEventThrottle : 0);
8104
8108
  const throttleScrollFn = scrollEventThrottle && onScrollProp ? throttledOnScroll : onScrollProp;
8105
8109
  const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_q = state.props.anchoredEndSpace) == null ? void 0 : _q.anchorIndex) !== (anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
@@ -8222,7 +8226,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8222
8226
  useDevChecks(props);
8223
8227
  }
8224
8228
  React3.useLayoutEffect(() => {
8225
- if (shouldResetFreshDataLayout) {
8229
+ const didDataChange = handledDataChangeEpochRef.current !== dataChangeEpoch;
8230
+ const didStartFreshData = handledFreshDataTransitionEpochRef.current !== freshDataTransitionEpoch;
8231
+ handledDataChangeEpochRef.current = dataChangeEpoch;
8232
+ handledFreshDataTransitionEpochRef.current = freshDataTransitionEpoch;
8233
+ if (didStartFreshData) {
8226
8234
  resetInitialRenderState(ctx, {
8227
8235
  resetInitialScroll: !!initialScrollProp,
8228
8236
  resetLayout: true
@@ -8230,8 +8238,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8230
8238
  }
8231
8239
  handleInitialScrollDataChange(ctx, {
8232
8240
  dataLength: dataProp.length,
8233
- didDataChange: didDataChangeLocal,
8234
- didStartFreshData: shouldResetFreshDataLayout,
8241
+ didDataChange,
8242
+ didStartFreshData,
8235
8243
  initialScrollAtEnd,
8236
8244
  latestInitialScroll: initialScrollProp,
8237
8245
  latestInitialScrollSessionKind: initialScrollUsesOffsetOnly ? "offset" : "bootstrap",
@@ -8241,8 +8249,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8241
8249
  }, [
8242
8250
  dataProp.length,
8243
8251
  dataKey,
8244
- didDataChangeLocal,
8245
- shouldResetFreshDataLayout,
8252
+ dataChangeEpoch,
8253
+ freshDataTransitionEpoch,
8246
8254
  initialScrollAtEnd,
8247
8255
  stylePaddingEndState,
8248
8256
  usesBootstrapInitialScroll
package/react.mjs CHANGED
@@ -8054,6 +8054,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8054
8054
  refState.current = ctx.state;
8055
8055
  }
8056
8056
  const state = refState.current;
8057
+ const handledDataChangeEpochRef = useRef(state.dataChangeEpoch);
8058
+ const handledFreshDataTransitionEpochRef = useRef(state.freshDataTransitionEpoch);
8057
8059
  const isFirstLocal = state.isFirst;
8058
8060
  const previousAdaptiveRender = state.props.adaptiveRender;
8059
8061
  const previousHideItemsUntilMeasured = state.props.hideItemsUntilMeasured;
@@ -8079,6 +8081,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8079
8081
  if (shouldResetFreshDataLayout) {
8080
8082
  state.freshDataTransitionEpoch += 1;
8081
8083
  }
8084
+ const dataChangeEpoch = state.dataChangeEpoch;
8085
+ const freshDataTransitionEpoch = state.freshDataTransitionEpoch;
8082
8086
  const throttledOnScroll = useThrottledOnScroll(onScrollProp != null ? onScrollProp : noopOnScroll, scrollEventThrottle != null ? scrollEventThrottle : 0);
8083
8087
  const throttleScrollFn = scrollEventThrottle && onScrollProp ? throttledOnScroll : onScrollProp;
8084
8088
  const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_q = state.props.anchoredEndSpace) == null ? void 0 : _q.anchorIndex) !== (anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
@@ -8201,7 +8205,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8201
8205
  useDevChecks(props);
8202
8206
  }
8203
8207
  useLayoutEffect(() => {
8204
- if (shouldResetFreshDataLayout) {
8208
+ const didDataChange = handledDataChangeEpochRef.current !== dataChangeEpoch;
8209
+ const didStartFreshData = handledFreshDataTransitionEpochRef.current !== freshDataTransitionEpoch;
8210
+ handledDataChangeEpochRef.current = dataChangeEpoch;
8211
+ handledFreshDataTransitionEpochRef.current = freshDataTransitionEpoch;
8212
+ if (didStartFreshData) {
8205
8213
  resetInitialRenderState(ctx, {
8206
8214
  resetInitialScroll: !!initialScrollProp,
8207
8215
  resetLayout: true
@@ -8209,8 +8217,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8209
8217
  }
8210
8218
  handleInitialScrollDataChange(ctx, {
8211
8219
  dataLength: dataProp.length,
8212
- didDataChange: didDataChangeLocal,
8213
- didStartFreshData: shouldResetFreshDataLayout,
8220
+ didDataChange,
8221
+ didStartFreshData,
8214
8222
  initialScrollAtEnd,
8215
8223
  latestInitialScroll: initialScrollProp,
8216
8224
  latestInitialScrollSessionKind: initialScrollUsesOffsetOnly ? "offset" : "bootstrap",
@@ -8220,8 +8228,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
8220
8228
  }, [
8221
8229
  dataProp.length,
8222
8230
  dataKey,
8223
- didDataChangeLocal,
8224
- shouldResetFreshDataLayout,
8231
+ dataChangeEpoch,
8232
+ freshDataTransitionEpoch,
8225
8233
  initialScrollAtEnd,
8226
8234
  stylePaddingEndState,
8227
8235
  usesBootstrapInitialScroll