@legendapp/list 1.0.0-beta.4 → 1.0.0-beta.40

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/reanimated.mjs CHANGED
@@ -1,7 +1,24 @@
1
1
  import { LegendList } from '@legendapp/list';
2
- import React from 'react';
2
+ import React, { useCallback } from 'react';
3
3
  import Animated from 'react-native-reanimated';
4
4
 
5
+ // src/reanimated.tsx
6
+ var useCombinedRef = (...refs) => {
7
+ const callback = useCallback((element) => {
8
+ for (const ref of refs) {
9
+ if (!ref) {
10
+ continue;
11
+ }
12
+ if (typeof ref === "function") {
13
+ ref(element);
14
+ } else {
15
+ ref.current = element;
16
+ }
17
+ }
18
+ }, refs);
19
+ return callback;
20
+ };
21
+
5
22
  // src/reanimated.tsx
6
23
  var LegendListForwardedRef = React.forwardRef(function LegendListForwardedRef2(props, ref) {
7
24
  const { refLegendList, ...rest } = props;
@@ -19,22 +36,9 @@ var LegendListForwardedRef = React.forwardRef(function LegendListForwardedRef2(p
19
36
  var AnimatedLegendListComponent = Animated.createAnimatedComponent(LegendListForwardedRef);
20
37
  var AnimatedLegendList = React.forwardRef(function AnimatedLegendList2(props, ref) {
21
38
  const { refScrollView, ...rest } = props;
22
- return /* @__PURE__ */ React.createElement(
23
- AnimatedLegendListComponent,
24
- {
25
- refLegendList: (r) => {
26
- if (ref) {
27
- if (typeof ref === "function") {
28
- ref(r);
29
- } else {
30
- ref.current = r;
31
- }
32
- }
33
- },
34
- ref: refScrollView,
35
- ...rest
36
- }
37
- );
39
+ const refLegendList = React.useRef(null);
40
+ const combinedRef = useCombinedRef(refLegendList, ref);
41
+ return /* @__PURE__ */ React.createElement(AnimatedLegendListComponent, { refLegendList: combinedRef, ref: refScrollView, ...rest });
38
42
  });
39
43
 
40
44
  export { AnimatedLegendList };