@legendapp/list 0.4.5 → 0.4.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 (3) hide show
  1. package/index.js +42 -32
  2. package/index.mjs +42 -32
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -86,7 +86,7 @@ function $View({ $key, $style, ...rest }) {
86
86
  return /* @__PURE__ */ React6__namespace.createElement(LeanView, { style, ...rest });
87
87
  }
88
88
  function InnerContainer({ id, getRenderedItem, recycleItems, ItemSeparatorComponent }) {
89
- const itemIndex = use$(`containerIndex${id}`);
89
+ const itemIndex = use$(`containerItemIndex${id}`);
90
90
  const numItems = ItemSeparatorComponent ? use$("numItems") : 0;
91
91
  if (itemIndex < 0) {
92
92
  return null;
@@ -133,7 +133,7 @@ var Container = ({
133
133
  $key: `containerPosition${id}`,
134
134
  $style: createStyle,
135
135
  onLayout: (event) => {
136
- const index = peek$(ctx, `containerIndex${id}`);
136
+ const index = peek$(ctx, `containerItemIndex${id}`);
137
137
  if (index >= 0) {
138
138
  const size = event.nativeEvent.layout[horizontal ? "width" : "height"];
139
139
  onLayout(index, size);
@@ -413,7 +413,7 @@ function isViewable(state, ctx, viewabilityConfig, key, scrollSize, item, index)
413
413
  function findContainerId(state, ctx, index) {
414
414
  const numContainers = peek$(ctx, "numContainers");
415
415
  for (let i = 0; i < numContainers; i++) {
416
- const itemIndex = peek$(ctx, `containerIndex${i}`);
416
+ const itemIndex = peek$(ctx, `containerItemIndex${i}`);
417
417
  if (itemIndex === index) {
418
418
  return i;
419
419
  }
@@ -548,14 +548,14 @@ var LegendListInner = React6.forwardRef(function LegendListInner2(props, forward
548
548
  refState.current.animFrameTotalSize = requestAnimationFrame(doAdd);
549
549
  }
550
550
  }, []);
551
- const getRenderedItem = React6.useCallback((index, containerIndex) => {
551
+ const getRenderedItem = React6.useCallback((index, containerId) => {
552
552
  var _a2, _b2, _c;
553
553
  const data2 = (_a2 = refState.current) == null ? void 0 : _a2.data;
554
554
  if (!data2) {
555
555
  return null;
556
556
  }
557
557
  const useViewability = (configId, callback) => {
558
- const key = containerIndex + configId;
558
+ const key = containerId + configId;
559
559
  useInit(() => {
560
560
  const value = ctx.mapViewabilityValues.get(key);
561
561
  if (value) {
@@ -572,15 +572,15 @@ var LegendListInner = React6.forwardRef(function LegendListInner2(props, forward
572
572
  };
573
573
  const useViewabilityAmount = (callback) => {
574
574
  useInit(() => {
575
- const value = ctx.mapViewabilityAmountValues.get(containerIndex);
575
+ const value = ctx.mapViewabilityAmountValues.get(containerId);
576
576
  if (value) {
577
577
  callback(value);
578
578
  }
579
579
  });
580
- ctx.mapViewabilityAmountCallbacks.set(containerIndex, callback);
580
+ ctx.mapViewabilityAmountCallbacks.set(containerId, callback);
581
581
  React6.useEffect(
582
582
  () => () => {
583
- ctx.mapViewabilityAmountCallbacks.delete(containerIndex);
583
+ ctx.mapViewabilityAmountCallbacks.delete(containerId);
584
584
  },
585
585
  []
586
586
  );
@@ -590,7 +590,7 @@ var LegendListInner = React6.forwardRef(function LegendListInner2(props, forward
590
590
  const state = refState.current;
591
591
  let prevIndex = index;
592
592
  let prevItem = state.data[index];
593
- const signal = `containerIndex${containerIndex}`;
593
+ const signal = `containerItemIndex${containerId}`;
594
594
  listen$(ctx, signal, () => {
595
595
  const data3 = state.data;
596
596
  if (data3) {
@@ -642,10 +642,7 @@ var LegendListInner = React6.forwardRef(function LegendListInner2(props, forward
642
642
  data: data2,
643
643
  scrollLength,
644
644
  scroll: scrollState,
645
- startNoBuffer: startNoBufferState,
646
- startBuffered: startBufferedState,
647
- endNoBuffer: endNoBufferState,
648
- endBuffered: endBufferedState
645
+ startBuffered: startBufferedState
649
646
  } = refState.current;
650
647
  if (!data2) {
651
648
  return;
@@ -709,20 +706,21 @@ var LegendListInner = React6.forwardRef(function LegendListInner2(props, forward
709
706
  let numContainers = prevNumContainers;
710
707
  for (let i = startBuffered; i <= endBuffered; i++) {
711
708
  let isContained = false;
709
+ const id = getId(i);
712
710
  for (let j = 0; j < numContainers; j++) {
713
- const index = peek$(ctx, `containerIndex${j}`);
714
- if (index === i) {
711
+ const index = peek$(ctx, `containerItemIndex${j}`);
712
+ const key = peek$(ctx, `containerItemKey${j}`);
713
+ if (index === i && key === id) {
715
714
  isContained = true;
716
715
  break;
717
716
  }
718
717
  }
719
718
  if (!isContained) {
720
- const id = getId(i);
721
719
  const top2 = positions.get(id) || 0;
722
720
  let furthestIndex = -1;
723
721
  let furthestDistance = 0;
724
722
  for (let u = 0; u < numContainers; u++) {
725
- const index = peek$(ctx, `containerIndex${u}`);
723
+ const index = peek$(ctx, `containerItemIndex${u}`);
726
724
  if (index < 0) {
727
725
  furthestIndex = u;
728
726
  break;
@@ -737,7 +735,8 @@ var LegendListInner = React6.forwardRef(function LegendListInner2(props, forward
737
735
  }
738
736
  }
739
737
  if (furthestIndex >= 0) {
740
- set$(ctx, `containerIndex${furthestIndex}`, i);
738
+ set$(ctx, `containerItemIndex${furthestIndex}`, i);
739
+ set$(ctx, `containerItemKey${furthestIndex}`, id);
741
740
  } else {
742
741
  if (__DEV__) {
743
742
  console.warn(
@@ -747,7 +746,8 @@ var LegendListInner = React6.forwardRef(function LegendListInner2(props, forward
747
746
  }
748
747
  const containerId = numContainers;
749
748
  numContainers++;
750
- set$(ctx, `containerIndex${containerId}`, i);
749
+ set$(ctx, `containerItemIndex${containerId}`, i);
750
+ set$(ctx, `containerItemKey${containerId}`, id);
751
751
  set$(ctx, `containerPosition${containerId}`, POSITION_OUT_OF_VIEW);
752
752
  }
753
753
  }
@@ -756,11 +756,12 @@ var LegendListInner = React6.forwardRef(function LegendListInner2(props, forward
756
756
  set$(ctx, "numContainers", numContainers);
757
757
  }
758
758
  for (let i = 0; i < numContainers; i++) {
759
- const itemIndex = peek$(ctx, `containerIndex${i}`);
759
+ const itemIndex = peek$(ctx, `containerItemIndex${i}`);
760
+ const itemKey = peek$(ctx, `containerItemKey${i}`);
760
761
  const item = data2[itemIndex];
761
762
  if (item) {
762
763
  const id = getId(itemIndex);
763
- if (itemIndex < startBuffered || itemIndex > endBuffered) {
764
+ if (itemKey !== id || itemIndex < startBuffered || itemIndex > endBuffered) {
764
765
  set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
765
766
  } else {
766
767
  const pos = (_c = positions.get(id)) != null ? _c : -1;
@@ -786,22 +787,22 @@ var LegendListInner = React6.forwardRef(function LegendListInner2(props, forward
786
787
  });
787
788
  }, []);
788
789
  useInit(() => {
789
- var _a2, _b2;
790
+ var _a2;
790
791
  refState.current.viewabilityConfigCallbackPairs = setupViewability(props);
791
792
  const scrollLength = refState.current.scrollLength;
792
793
  const averageItemSize = estimatedItemSize != null ? estimatedItemSize : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(0, data[0]);
793
794
  const numContainers = initialNumContainers || Math.ceil((scrollLength + scrollBuffer * 2) / averageItemSize) + 4;
794
795
  for (let i = 0; i < numContainers; i++) {
795
- set$(ctx, `containerIndex${i}`, -1);
796
+ set$(ctx, `containerItemIndex${i}`, -1);
796
797
  set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
797
798
  }
798
799
  set$(ctx, "numContainers", numContainers);
799
800
  calculateItemsInView();
800
- const sizes = (_a2 = refState.current) == null ? void 0 : _a2.sizes;
801
+ const sizes = refState.current.sizes;
801
802
  let totalSize = 0;
802
803
  for (let i = 0; i < data.length; i++) {
803
804
  const id = getId(i);
804
- totalSize += (_b2 = sizes.get(id)) != null ? _b2 : getItemSize(i, data[i]);
805
+ totalSize += (_a2 = sizes.get(id)) != null ? _a2 : getItemSize(i, data[i]);
805
806
  }
806
807
  addTotalSize(totalSize);
807
808
  });
@@ -829,9 +830,9 @@ var LegendListInner = React6.forwardRef(function LegendListInner2(props, forward
829
830
  const numContainers = peek$(ctx, "numContainers");
830
831
  if (data.length < numContainers) {
831
832
  for (let i = 0; i < numContainers; i++) {
832
- const itemIndex = peek$(ctx, `containerIndex${i}`);
833
+ const itemIndex = peek$(ctx, `containerItemIndex${i}`);
833
834
  if (itemIndex >= data.length) {
834
- set$(ctx, `containerIndex${i}`, -1);
835
+ set$(ctx, `containerItemIndex${i}`, -1);
835
836
  }
836
837
  }
837
838
  }
@@ -839,19 +840,19 @@ var LegendListInner = React6.forwardRef(function LegendListInner2(props, forward
839
840
  checkAtBottom();
840
841
  }, [data]);
841
842
  const updateItemSize = React6.useCallback((index, size) => {
842
- var _a2, _b2, _c, _d;
843
+ var _a2, _b2, _c;
843
844
  const data2 = (_a2 = refState.current) == null ? void 0 : _a2.data;
844
845
  if (!data2) {
845
846
  return;
846
847
  }
847
- const sizes = (_b2 = refState.current) == null ? void 0 : _b2.sizes;
848
+ const sizes = refState.current.sizes;
848
849
  const id = getId(index);
849
- const wasInFirstRender = (_c = refState.current) == null ? void 0 : _c.idsInFirstRender.has(id);
850
+ const wasInFirstRender = (_b2 = refState.current) == null ? void 0 : _b2.idsInFirstRender.has(id);
850
851
  const prevSize = sizes.get(id) || (wasInFirstRender ? getItemSize(index, data2[index]) : 0);
851
852
  if (!prevSize || Math.abs(prevSize - size) > 0.5) {
852
853
  sizes.set(id, size);
853
854
  addTotalSize(size - prevSize);
854
- if (((_d = refState.current) == null ? void 0 : _d.isAtBottom) && maintainScrollAtEnd) {
855
+ if (((_c = refState.current) == null ? void 0 : _c.isAtBottom) && maintainScrollAtEnd) {
855
856
  requestAnimationFrame(() => {
856
857
  var _a3;
857
858
  (_a3 = refScroller.current) == null ? void 0 : _a3.scrollToEnd({
@@ -878,6 +879,15 @@ var LegendListInner = React6.forwardRef(function LegendListInner2(props, forward
878
879
  const onLayout = React6.useCallback((event) => {
879
880
  const scrollLength = event.nativeEvent.layout[horizontal ? "width" : "height"];
880
881
  refState.current.scrollLength = scrollLength;
882
+ if (__DEV__) {
883
+ const isWidthZero = event.nativeEvent.layout.width === 0;
884
+ const isHeightZero = event.nativeEvent.layout.height === 0;
885
+ if (isWidthZero || isHeightZero) {
886
+ console.warn(
887
+ `[legend-list] List ${isWidthZero ? "width" : "height"} is 0. You may need to set a style or \`flex: \` for the list, because children are absolutely positioned.`
888
+ );
889
+ }
890
+ }
881
891
  }, []);
882
892
  const handleScroll = React6.useCallback(
883
893
  (event, fromSelf) => {
@@ -931,7 +941,7 @@ var LegendListInner = React6.forwardRef(function LegendListInner2(props, forward
931
941
  {
932
942
  ...rest,
933
943
  contentContainerStyle,
934
- style,
944
+ style: [style],
935
945
  horizontal,
936
946
  refScroller,
937
947
  initialContentOffset,
package/index.mjs CHANGED
@@ -65,7 +65,7 @@ function $View({ $key, $style, ...rest }) {
65
65
  return /* @__PURE__ */ React6.createElement(LeanView, { style, ...rest });
66
66
  }
67
67
  function InnerContainer({ id, getRenderedItem, recycleItems, ItemSeparatorComponent }) {
68
- const itemIndex = use$(`containerIndex${id}`);
68
+ const itemIndex = use$(`containerItemIndex${id}`);
69
69
  const numItems = ItemSeparatorComponent ? use$("numItems") : 0;
70
70
  if (itemIndex < 0) {
71
71
  return null;
@@ -112,7 +112,7 @@ var Container = ({
112
112
  $key: `containerPosition${id}`,
113
113
  $style: createStyle,
114
114
  onLayout: (event) => {
115
- const index = peek$(ctx, `containerIndex${id}`);
115
+ const index = peek$(ctx, `containerItemIndex${id}`);
116
116
  if (index >= 0) {
117
117
  const size = event.nativeEvent.layout[horizontal ? "width" : "height"];
118
118
  onLayout(index, size);
@@ -392,7 +392,7 @@ function isViewable(state, ctx, viewabilityConfig, key, scrollSize, item, index)
392
392
  function findContainerId(state, ctx, index) {
393
393
  const numContainers = peek$(ctx, "numContainers");
394
394
  for (let i = 0; i < numContainers; i++) {
395
- const itemIndex = peek$(ctx, `containerIndex${i}`);
395
+ const itemIndex = peek$(ctx, `containerItemIndex${i}`);
396
396
  if (itemIndex === index) {
397
397
  return i;
398
398
  }
@@ -527,14 +527,14 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
527
527
  refState.current.animFrameTotalSize = requestAnimationFrame(doAdd);
528
528
  }
529
529
  }, []);
530
- const getRenderedItem = useCallback((index, containerIndex) => {
530
+ const getRenderedItem = useCallback((index, containerId) => {
531
531
  var _a2, _b2, _c;
532
532
  const data2 = (_a2 = refState.current) == null ? void 0 : _a2.data;
533
533
  if (!data2) {
534
534
  return null;
535
535
  }
536
536
  const useViewability = (configId, callback) => {
537
- const key = containerIndex + configId;
537
+ const key = containerId + configId;
538
538
  useInit(() => {
539
539
  const value = ctx.mapViewabilityValues.get(key);
540
540
  if (value) {
@@ -551,15 +551,15 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
551
551
  };
552
552
  const useViewabilityAmount = (callback) => {
553
553
  useInit(() => {
554
- const value = ctx.mapViewabilityAmountValues.get(containerIndex);
554
+ const value = ctx.mapViewabilityAmountValues.get(containerId);
555
555
  if (value) {
556
556
  callback(value);
557
557
  }
558
558
  });
559
- ctx.mapViewabilityAmountCallbacks.set(containerIndex, callback);
559
+ ctx.mapViewabilityAmountCallbacks.set(containerId, callback);
560
560
  useEffect(
561
561
  () => () => {
562
- ctx.mapViewabilityAmountCallbacks.delete(containerIndex);
562
+ ctx.mapViewabilityAmountCallbacks.delete(containerId);
563
563
  },
564
564
  []
565
565
  );
@@ -569,7 +569,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
569
569
  const state = refState.current;
570
570
  let prevIndex = index;
571
571
  let prevItem = state.data[index];
572
- const signal = `containerIndex${containerIndex}`;
572
+ const signal = `containerItemIndex${containerId}`;
573
573
  listen$(ctx, signal, () => {
574
574
  const data3 = state.data;
575
575
  if (data3) {
@@ -621,10 +621,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
621
621
  data: data2,
622
622
  scrollLength,
623
623
  scroll: scrollState,
624
- startNoBuffer: startNoBufferState,
625
- startBuffered: startBufferedState,
626
- endNoBuffer: endNoBufferState,
627
- endBuffered: endBufferedState
624
+ startBuffered: startBufferedState
628
625
  } = refState.current;
629
626
  if (!data2) {
630
627
  return;
@@ -688,20 +685,21 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
688
685
  let numContainers = prevNumContainers;
689
686
  for (let i = startBuffered; i <= endBuffered; i++) {
690
687
  let isContained = false;
688
+ const id = getId(i);
691
689
  for (let j = 0; j < numContainers; j++) {
692
- const index = peek$(ctx, `containerIndex${j}`);
693
- if (index === i) {
690
+ const index = peek$(ctx, `containerItemIndex${j}`);
691
+ const key = peek$(ctx, `containerItemKey${j}`);
692
+ if (index === i && key === id) {
694
693
  isContained = true;
695
694
  break;
696
695
  }
697
696
  }
698
697
  if (!isContained) {
699
- const id = getId(i);
700
698
  const top2 = positions.get(id) || 0;
701
699
  let furthestIndex = -1;
702
700
  let furthestDistance = 0;
703
701
  for (let u = 0; u < numContainers; u++) {
704
- const index = peek$(ctx, `containerIndex${u}`);
702
+ const index = peek$(ctx, `containerItemIndex${u}`);
705
703
  if (index < 0) {
706
704
  furthestIndex = u;
707
705
  break;
@@ -716,7 +714,8 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
716
714
  }
717
715
  }
718
716
  if (furthestIndex >= 0) {
719
- set$(ctx, `containerIndex${furthestIndex}`, i);
717
+ set$(ctx, `containerItemIndex${furthestIndex}`, i);
718
+ set$(ctx, `containerItemKey${furthestIndex}`, id);
720
719
  } else {
721
720
  if (__DEV__) {
722
721
  console.warn(
@@ -726,7 +725,8 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
726
725
  }
727
726
  const containerId = numContainers;
728
727
  numContainers++;
729
- set$(ctx, `containerIndex${containerId}`, i);
728
+ set$(ctx, `containerItemIndex${containerId}`, i);
729
+ set$(ctx, `containerItemKey${containerId}`, id);
730
730
  set$(ctx, `containerPosition${containerId}`, POSITION_OUT_OF_VIEW);
731
731
  }
732
732
  }
@@ -735,11 +735,12 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
735
735
  set$(ctx, "numContainers", numContainers);
736
736
  }
737
737
  for (let i = 0; i < numContainers; i++) {
738
- const itemIndex = peek$(ctx, `containerIndex${i}`);
738
+ const itemIndex = peek$(ctx, `containerItemIndex${i}`);
739
+ const itemKey = peek$(ctx, `containerItemKey${i}`);
739
740
  const item = data2[itemIndex];
740
741
  if (item) {
741
742
  const id = getId(itemIndex);
742
- if (itemIndex < startBuffered || itemIndex > endBuffered) {
743
+ if (itemKey !== id || itemIndex < startBuffered || itemIndex > endBuffered) {
743
744
  set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
744
745
  } else {
745
746
  const pos = (_c = positions.get(id)) != null ? _c : -1;
@@ -765,22 +766,22 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
765
766
  });
766
767
  }, []);
767
768
  useInit(() => {
768
- var _a2, _b2;
769
+ var _a2;
769
770
  refState.current.viewabilityConfigCallbackPairs = setupViewability(props);
770
771
  const scrollLength = refState.current.scrollLength;
771
772
  const averageItemSize = estimatedItemSize != null ? estimatedItemSize : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(0, data[0]);
772
773
  const numContainers = initialNumContainers || Math.ceil((scrollLength + scrollBuffer * 2) / averageItemSize) + 4;
773
774
  for (let i = 0; i < numContainers; i++) {
774
- set$(ctx, `containerIndex${i}`, -1);
775
+ set$(ctx, `containerItemIndex${i}`, -1);
775
776
  set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
776
777
  }
777
778
  set$(ctx, "numContainers", numContainers);
778
779
  calculateItemsInView();
779
- const sizes = (_a2 = refState.current) == null ? void 0 : _a2.sizes;
780
+ const sizes = refState.current.sizes;
780
781
  let totalSize = 0;
781
782
  for (let i = 0; i < data.length; i++) {
782
783
  const id = getId(i);
783
- totalSize += (_b2 = sizes.get(id)) != null ? _b2 : getItemSize(i, data[i]);
784
+ totalSize += (_a2 = sizes.get(id)) != null ? _a2 : getItemSize(i, data[i]);
784
785
  }
785
786
  addTotalSize(totalSize);
786
787
  });
@@ -808,9 +809,9 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
808
809
  const numContainers = peek$(ctx, "numContainers");
809
810
  if (data.length < numContainers) {
810
811
  for (let i = 0; i < numContainers; i++) {
811
- const itemIndex = peek$(ctx, `containerIndex${i}`);
812
+ const itemIndex = peek$(ctx, `containerItemIndex${i}`);
812
813
  if (itemIndex >= data.length) {
813
- set$(ctx, `containerIndex${i}`, -1);
814
+ set$(ctx, `containerItemIndex${i}`, -1);
814
815
  }
815
816
  }
816
817
  }
@@ -818,19 +819,19 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
818
819
  checkAtBottom();
819
820
  }, [data]);
820
821
  const updateItemSize = useCallback((index, size) => {
821
- var _a2, _b2, _c, _d;
822
+ var _a2, _b2, _c;
822
823
  const data2 = (_a2 = refState.current) == null ? void 0 : _a2.data;
823
824
  if (!data2) {
824
825
  return;
825
826
  }
826
- const sizes = (_b2 = refState.current) == null ? void 0 : _b2.sizes;
827
+ const sizes = refState.current.sizes;
827
828
  const id = getId(index);
828
- const wasInFirstRender = (_c = refState.current) == null ? void 0 : _c.idsInFirstRender.has(id);
829
+ const wasInFirstRender = (_b2 = refState.current) == null ? void 0 : _b2.idsInFirstRender.has(id);
829
830
  const prevSize = sizes.get(id) || (wasInFirstRender ? getItemSize(index, data2[index]) : 0);
830
831
  if (!prevSize || Math.abs(prevSize - size) > 0.5) {
831
832
  sizes.set(id, size);
832
833
  addTotalSize(size - prevSize);
833
- if (((_d = refState.current) == null ? void 0 : _d.isAtBottom) && maintainScrollAtEnd) {
834
+ if (((_c = refState.current) == null ? void 0 : _c.isAtBottom) && maintainScrollAtEnd) {
834
835
  requestAnimationFrame(() => {
835
836
  var _a3;
836
837
  (_a3 = refScroller.current) == null ? void 0 : _a3.scrollToEnd({
@@ -857,6 +858,15 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
857
858
  const onLayout = useCallback((event) => {
858
859
  const scrollLength = event.nativeEvent.layout[horizontal ? "width" : "height"];
859
860
  refState.current.scrollLength = scrollLength;
861
+ if (__DEV__) {
862
+ const isWidthZero = event.nativeEvent.layout.width === 0;
863
+ const isHeightZero = event.nativeEvent.layout.height === 0;
864
+ if (isWidthZero || isHeightZero) {
865
+ console.warn(
866
+ `[legend-list] List ${isWidthZero ? "width" : "height"} is 0. You may need to set a style or \`flex: \` for the list, because children are absolutely positioned.`
867
+ );
868
+ }
869
+ }
860
870
  }, []);
861
871
  const handleScroll = useCallback(
862
872
  (event, fromSelf) => {
@@ -910,7 +920,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
910
920
  {
911
921
  ...rest,
912
922
  contentContainerStyle,
913
- style,
923
+ style: [style],
914
924
  horizontal,
915
925
  refScroller,
916
926
  initialContentOffset,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "legend-list",
5
5
  "sideEffects": false,
6
6
  "private": false,