This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {FlatList, Text, StyleSheet} from 'react-native'; | |
export default class MySlider extends React.Component { | |
state = { | |
data: ['A', 'B', 'C'], | |
}; | |
render() { | |
return ( | |
<View style={styles.container}> | |
<FlatList |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {FlatList, View, StyleSheet, Dimensions} from 'react-native'; | |
export default class MySlider extends React.Component { | |
... | |
render() { | |
return ( | |
<View style={styles.container}> | |
<FlatList | |
… | |
renderItem={({item}) => <Text style={styles.item}>{item}</Text>} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<View style={styles.container}> | |
<FlatList | |
ref={ref => { | |
this.flatListRef = ref; | |
}} | |
onViewableItemsChanged={this.onViewableItemsChanged} | |
.../> | |
<View style={styles.buttonContainer}> | |
<Button title={'Previous'} onPress={this.scrollPrevious} /> | |
<Button title={'Next'} onPress={this.scrollNext} /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
currentIndex = 0; | |
scrollNext = () => { | |
if (this.currentIndex !== this.state.data.length - 1) { | |
this.flatListRef.scrollToIndex({ | |
index: this.currentIndex + 1, | |
animated: true, | |
}); | |
} | |
}; | |
scrollPrevious = () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Creator Asim Karel | |
* https://github.com/AsimKarel | |
* | |
*/ | |
import React from 'react'; | |
import { | |
FlatList, | |
Button, |