Skip to content

Commit

Permalink
fix onChangeIndex iOS (#183)
Browse files Browse the repository at this point in the history
* fix callback onChangeIndex

* fix change index android
  • Loading branch information
phuocantd authored Apr 23, 2024
1 parent 40243d3 commit 9b26891
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/SwiperFlatList/SwiperFlatList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useRef } from 'react';
import {
FlatList as RNFlatList,
FlatListProps,
Expand Down Expand Up @@ -216,6 +216,10 @@ export const SwiperFlatList = React.forwardRef(
[onViewableItemsChanged],
);

const viewabilityConfigCallbackPairs = useRef<any>([
{ onViewableItemsChanged:_onViewableItemsChanged, },

Check failure on line 220 in src/components/SwiperFlatList/SwiperFlatList.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

Replace `_onViewableItemsChanged,` with `·_onViewableItemsChanged`

Check warning on line 220 in src/components/SwiperFlatList/SwiperFlatList.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

Unexpected trailing comma

Check failure on line 220 in src/components/SwiperFlatList/SwiperFlatList.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `_onViewableItemsChanged,` with `·_onViewableItemsChanged`

Check warning on line 220 in src/components/SwiperFlatList/SwiperFlatList.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected trailing comma
]);

const flatListProps: FlatListProps<unknown> & { ref: React.RefObject<RNFlatList<unknown>> } = {
scrollEnabled,
ref: flatListElement,
Expand All @@ -242,7 +246,8 @@ export const SwiperFlatList = React.forwardRef(
itemVisiblePercentThreshold: ITEM_VISIBLE_PERCENT_THRESHOLD,
...viewabilityConfig,
},
onViewableItemsChanged: _onViewableItemsChanged,
viewabilityConfigCallbackPairs: Platform.OS === 'ios'? viewabilityConfigCallbackPairs.current : undefined,

Check failure on line 249 in src/components/SwiperFlatList/SwiperFlatList.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

Replace `·Platform.OS·===·'ios'` with `⏎········Platform.OS·===·'ios'·`

Check warning on line 249 in src/components/SwiperFlatList/SwiperFlatList.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

Operator '?' must be spaced

Check failure on line 249 in src/components/SwiperFlatList/SwiperFlatList.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `·Platform.OS·===·'ios'` with `⏎········Platform.OS·===·'ios'·`

Check warning on line 249 in src/components/SwiperFlatList/SwiperFlatList.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Operator '?' must be spaced
onViewableItemsChanged: Platform.OS === 'android'? _onViewableItemsChanged : undefined,

Check failure on line 250 in src/components/SwiperFlatList/SwiperFlatList.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

Insert `·`

Check warning on line 250 in src/components/SwiperFlatList/SwiperFlatList.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

Operator '?' must be spaced

Check failure on line 250 in src/components/SwiperFlatList/SwiperFlatList.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Insert `·`

Check warning on line 250 in src/components/SwiperFlatList/SwiperFlatList.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Operator '?' must be spaced
// debug: true, // for debug
testID: e2eID,
};
Expand Down

0 comments on commit 9b26891

Please sign in to comment.