Skip to content

Instantly share code, notes, and snippets.

@afaquejam
Created October 4, 2020 07:28
Show Gist options
  • Save afaquejam/72d0880c25a76f2e3f44b297a07c40ef to your computer and use it in GitHub Desktop.
Save afaquejam/72d0880c25a76f2e3f44b297a07c40ef to your computer and use it in GitHub Desktop.
React Pagination Dot
import { StatusBar } from 'expo-status-bar';
import React, { useState } from 'react';
import { StyleSheet, Text, View, Button } from 'react-native';
import PaginationDot from 'react-native-animated-pagination-dot';
export default function App() {
const [currentPage, setCurrentPage] = useState(0);
const maxPage = 20;
const color = 'black';
return (
<View style={styles.container}>
<Button
onPress={() => {
if (currentPage !== 0) {
setCurrentPage(currentPage - 1);
}
}}
title="Before"
/>
<PaginationDot
activeDotColor={color}
curPage={currentPage}
maxPage={maxPage}
sizeRatio={1.0}
/>
<Button
onPress={() => {
if (currentPage !== maxPage) {
setCurrentPage(currentPage + 1);
}
}}
title="After"
/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'row',
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment