Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-pager-view

Package Overview
Dependencies
Maintainers
2
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-pager-view

React Native wrapper for Android and iOS ViewPager

  • 6.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
158K
decreased by-61.25%
Maintainers
2
Weekly downloads
 
Created

What is react-native-pager-view?

The react-native-pager-view package is a versatile and performant library for creating swipeable views in React Native applications. It allows developers to implement horizontal and vertical paging with smooth animations and customizable options.

What are react-native-pager-view's main functionalities?

Basic Pager View

This code demonstrates a basic implementation of a pager view with three pages. Each page contains a simple text element.

import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import PagerView from 'react-native-pager-view';

const BasicPagerView = () => (
  <PagerView style={styles.pagerView} initialPage={0}>
    <View key="1" style={styles.pageStyle}>
      <Text>First page</Text>
    </View>
    <View key="2" style={styles.pageStyle}>
      <Text>Second page</Text>
    </View>
    <View key="3" style={styles.pageStyle}>
      <Text>Third page</Text>
    </View>
  </PagerView>
);

const styles = StyleSheet.create({
  pagerView: {
    flex: 1,
  },
  pageStyle: {
    justifyContent: 'center',
    alignItems: 'center',
  },
});

export default BasicPagerView;

Vertical Pager View

This code demonstrates how to create a vertical pager view by setting the orientation prop to 'vertical'.

import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import PagerView from 'react-native-pager-view';

const VerticalPagerView = () => (
  <PagerView style={styles.pagerView} initialPage={0} orientation="vertical">
    <View key="1" style={styles.pageStyle}>
      <Text>First page</Text>
    </View>
    <View key="2" style={styles.pageStyle}>
      <Text>Second page</Text>
    </View>
    <View key="3" style={styles.pageStyle}>
      <Text>Third page</Text>
    </View>
  </PagerView>
);

const styles = StyleSheet.create({
  pagerView: {
    flex: 1,
  },
  pageStyle: {
    justifyContent: 'center',
    alignItems: 'center',
  },
});

export default VerticalPagerView;

Controlled Pager View

This code demonstrates a controlled pager view where the current page can be programmatically set using a button.

import React, { useState } from 'react';
import { View, Text, Button, StyleSheet } from 'react-native';
import PagerView from 'react-native-pager-view';

const ControlledPagerView = () => {
  const [page, setPage] = useState(0);

  return (
    <View style={{ flex: 1 }}>
      <PagerView style={styles.pagerView} initialPage={0} page={page} onPageSelected={e => setPage(e.nativeEvent.position)}>
        <View key="1" style={styles.pageStyle}>
          <Text>First page</Text>
        </View>
        <View key="2" style={styles.pageStyle}>
          <Text>Second page</Text>
        </View>
        <View key="3" style={styles.pageStyle}>
          <Text>Third page</Text>
        </View>
      </PagerView>
      <Button title="Go to next page" onPress={() => setPage(page + 1)} />
    </View>
  );
};

const styles = StyleSheet.create({
  pagerView: {
    flex: 1,
  },
  pageStyle: {
    justifyContent: 'center',
    alignItems: 'center',
  },
});

export default ControlledPagerView;

Other packages similar to react-native-pager-view

Keywords

FAQs

Package last updated on 06 Sep 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc