react-native-swiper-flatlist is a React Native carousel/swiper component built on top of FlatList. It supports iOS, Android, and Web (via react-native-web), with features including autoplay, pagination, gesture handling, RTL support, and imperative navigation via refs.
- Version: 3.2.5
- License: Apache-2.0
- Package manager: pnpm 10.29.3
- Entry point:
index.ts
├── index.ts # Main entry — exports SwiperFlatList, Pagination, and types
├── WithGestureHandler.tsx # SwiperFlatListWithGestureHandler (react-native-gesture-handler variant)
├── src/
│ ├── components/
│ │ ├── SwiperFlatList/
│ │ │ ├── SwiperFlatList.tsx # Main component implementation
│ │ │ ├── SwiperFlatListProps.tsx # Props type definitions
│ │ │ ├── SwiperFlatList.web.ts # Web platform variant
│ │ │ └── test.tsx # Unit tests
│ │ ├── Pagination/
│ │ │ ├── Pagination.tsx # Pagination dots component
│ │ │ ├── PaginationProps.tsx # Pagination type definitions
│ │ │ └── test.tsx # Unit tests
│ │ └── index.ts # Component barrel exports
│ └── themes/
│ ├── colors.ts # Color constants (white, gray)
│ └── layout.ts # Responsive spacing utilities
├── example/ # Expo example app (SDK 48, RN 0.71.6)
│ ├── src/ # Example components demonstrating usage
│ └── e2e/ # Detox E2E tests
└── old-rn-example/ # Legacy React Native example (not actively maintained)
pnpm tsc # TypeScript type checking (strict mode, noEmit)
pnpm lint # ESLint on index.ts, src/, example/scripts, example/src
pnpm lint:fix # ESLint with auto-fix
pnpm test # Jest unit tests (alias for pnpm jest)
pnpm test:watch # Jest in watch modecd example
pnpm install
pnpm start # Expo dev server
pnpm ios # Run on iOS
pnpm android # Run on Android
pnpm web # Run on web- Prettier: single quotes, 100-char print width, trailing commas
- ESLint: extends
@react-native-community, inline styles allowed - Indentation: 2 spaces
- Line endings: LF
- Strict mode enabled (
strict: true) - JSX mode:
react-native - Target:
esnext, module resolution:node - No emit — TypeScript is used for type checking only; Babel handles transpilation
- Components use PascalCase directories:
SwiperFlatList/,Pagination/ - Props are in separate
*Props.tsxfiles alongside the component - Tests are co-located as
test.tsxwithin each component directory - Web platform variants use
.web.tsextension
- Functional component with
React.forwardRefanduseImperativeHandlefor ref API useRef,useState,useEffect,useCallbackhooks throughout- Platform-specific files (
.web.ts) for web compatibility - Viewability-based index tracking (60% visibility threshold)
- Framework: Jest 24.8.0 with
react-nativepreset - Library: react-native-testing-library 1.11.1
- Snapshot tests: committed in
__snapshots__/directories - E2E tests: Detox (in
example/e2e/), run via Bitrise CI - Test files are at
src/components/*/test.tsx - Ignored paths:
example/,old-rn-example/
When updating snapshots after intentional visual changes:
pnpm jest --updateSnapshot- Triggers on all pushes and pull requests
- Node.js 24.x
- Uses
pnpm/action-setup@v4for pnpm installation - Steps:
pnpm install→pnpm tsc→pnpm lint→pnpm jest
SwiperFlatList(default export + named export) — main componentPagination— pagination dots component (for custom use)SwiperFlatListProps— type exportPaginationProps— type export
SwiperFlatListWithGestureHandler— variant using react-native-gesture-handler
getCurrentIndex()/getPrevIndex()— read current/previous indexscrollToIndex({index, animated?})— navigate to a specific slidegoToFirstIndex()/goToLastIndex()— jump to first/last slide
- The component wraps React Native's
FlatListwithpagingEnabledand horizontal scrolling - Index changes are detected via
onViewableItemsChangedwith a 60% visibility threshold - Autoplay uses
setIntervalwith configurable delay, loop, and direction - RTL support uses
I18nManager.isRTLfor directional calculations - The
disableGestureprop works by overlaying aViewwithonTouchStart/onTouchEndthat captures gestures renderAllprop controls whetherwindowSizeis set to render all items upfront or use default windowing- Peer dependency:
react-native >= 0.59.0
Before considering any work done, always complete the following steps:
- Run
pnpm installto ensure all dependencies are up to date - Run
pnpm lint(orpnpm lint:fix) to verify there are no linting errors - Run
pnpm tscto verify there are no TypeScript errors - Run
pnpm testto verify all unit tests pass - If snapshots changed intentionally, run
pnpm jest --updateSnapshot