Socket
Book a DemoInstallSign in
Socket

react-native-swiper-flatlist

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-swiper-flatlist

React native swiper flatlist component

Source
npmnpm
Version
2.0.3
Version published
Weekly downloads
16K
3.92%
Maintainers
1
Weekly downloads
 
Created
Source

:point_up_2: Swiper FlatList component

platforms npm npm travis license

Demo

Installation

yarn add react-native-swiper-flatlist

or

npm install react-native-swiper-flatlist --save

Notice

Version 2.x was re-implemented using React Hooks so it only works with version 0.59 or above

react-native-swiper-flatlistreact-native
1.x<= 0.58
2.x>= 0.59

Example

Expo

Example

Code

import React, { PureComponent } from 'react';
import { Text, Dimensions, Image, StyleSheet, View } from 'react-native';

import SwiperFlatList from 'react-native-swiper-flatlist';

export default class App extends PureComponent {
  render() {
    return (
      <View style={styles.container}>
        <SwiperFlatList
          autoplay
          autoplayDelay={2}
          autoplayLoop
          index={2}
          showPagination
        >
          <View style={[styles.child, { backgroundColor: 'tomato' }]}>
            <Text style={styles.text}>1</Text>
          </View>
          <View style={[styles.child, { backgroundColor: 'thistle' }]}>
            <Text style={styles.text}>2</Text>
          </View>
          <View style={[styles.child, { backgroundColor: 'skyblue' }]}>
            <Text style={styles.text}>3</Text>
          </View>
          <View style={[styles.child, { backgroundColor: 'teal' }]}>
            <Text style={styles.text}>4</Text>
          </View>
        </SwiperFlatList>
      </View>
    );
  }
}

export const { width, height } = Dimensions.get('window');

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: 'white'
  },
  child: {
    height: height * 0.5,
    width,
    justifyContent: 'center'
  },
  text: {
    fontSize: width * 0.5,
    textAlign: 'center'
  }
});

Code example

Props

PropDefaultTypeDescription
datanot required if children is usedarrayData to use in renderItem
children-nodeChildren elements
renderItemnot required if children is usedfuncTakes an item from data and renders it into the list
onMomentumScrollEnd-funcCalled after scroll end and the first parameter is the current index
verticalfalseboolShow vertical swiper
index0numberIndex to start
renderAllfalseboolRender all the items before display it
Pagination
showPaginationfalseboolShow pagination
paginationDefaultColorgraystringPagination color
paginationActiveColorwhitestringPagination color
paginationStyle{}ViewPropTypes.styleStyle object for container
paginationStyleItem{}ViewPropTypes.styleStyle object for item (dot)
PaginationComponentComponentnodeOverwrite Pagination component
Autoplay
autoplayfalseboolChange index automatically
autoplayDelay3numberDelay between every page in seconds
autoplayLoopfalseboolContinue playing after reach end
autoplayInvertDirectionfalseboolInvert auto play direction
disableGesturefalseboolDisable swipe gesture

More props

This is a wrapper around Flatlist, all their props works well and the inherited props too (from ScrollView and VirtualizedList)

Functions

NameParamsUse
scrollToIndex{ index: number, animated: bool?}Scroll to the index
getCurrentIndex-Returns the current index
getPrevIndex-Returns the previous index
onChangeIndex{ index: number, prevIndex: number}Executed every time the index change, the index change when the user reaches 60% of the next screen
goToFirstIndex-Go to the first index
goToLastIndex-Go to the last index

Limitations

  • Vertical pagination is not supported on Android. Doc
  • react-native-web is not supported, due to the lack of support of some props used in this library. Expo example

Author

Gustavo Gard

Keywords

swiper flatlist

FAQs

Package last updated on 11 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts