react-native-viewpager
react-native-viewpager copied to clipboard
Cant even use ViewPager based on example shown in library
I am trying to implement ViewPager according to the example which is available in the library itself.
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
Dimensions,
} from 'react-native';
import ViewPager from 'react-native-viewpager';
export default class App extends Component {
constructor(props) {
super(props);
this.dataSource = new ViewPager.DataSource({
pageHasChanged: (p1, p2) => p1 !== p2,
});
this.state = {
datasource: this.dataSource.cloneWithPages(["text 1", "text 2"])
}
}
_renderPage(data,pageID) {
console.log('rendeering page with data', data);
return (
<Text style={[styles.page, styles.buttonText]}>{data}</Text>
);
}
render() {
return (
<View style={styles.container}>
<ViewPager
style={styles.container}
dataSource={this.state.dataSource}
renderPage={this._renderPage}/>
</View>
);
}
}
const bgColor = '#ED784F';
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: bgColor,
}
});
This is what i get in my app
Hello @NishantDesai1306 I have the same issue with the example on the library. Do you find any solution to solve your problem? I try to copy and paste the same code to my project but I doesn't work.