Reputation: 178
when I implement Image-slider on my application using this example that time I have faced this error.
import React,{Component} from 'react'
import {View,Text,TouchableOpacity, ViewPagerAndroid} from 'react-native'
import Infoslider from 'react-native-infoslider'
export default class example extends Component {
constructor(props) {
super(props);
this.state = {
data:[
{
title:"Hello World",
text:"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard",
image: require('../Images/Group.png')}
]
};
}
render() {
return (
<Infoslider
data={this.state.data} />
);
}
}
Upvotes: 8
Views: 8406
Reputation: 1910
You might also need to update your babel version and runtime in case you have the 'token not recognized' error. Update the babel version following these steps:
npm install @babel/core@^7.9.0
npm install @babel/runtime@^7.9.2
npm install typescript@^3.8.3
rm -rf node_modules
npm install
npm start -- --reset-cache
Upvotes: 0
Reputation: 491
I solve it by:
install this module: react-native-community / viewpager
Go to the file: node_modules\react-native-swiper\src\index.js, and : add this line: import ViewPager from '@react-native-community/viewpager'; and remove this ViewPagerAndroid from the imports.
This works for me
Upvotes: 4
Reputation: 41
You can resolve this error by updating react-native-swiper to latest(nightly) and in case you don't want to update react-native-swiper then install @react-native-community/viewpager and remove import of ViewPagerAndroid from react-native and import it from @react-native-community/viewpager
Upvotes: 2
Reputation: 106
You should update the react-native-swiper module to nightly. Then, npm clear cache.
Please follow this:
- cd android
- ./gradlew clean
- cd ..
- yarn remove react-native-swiper
- yarn add react-native-swiper@nightly
- rm -rf node_modules
- npm cache clean --force
- npm install
- react-native run-android
it will work. but if no, please restart system.
Upvotes: 9
Reputation: 12235
You need to first yarn add @react-native-community/viewpager
or npm i @react-native-community/viewpager
.
Thena after that remove ViewPagerAndroid from 'react-native' in imports and use
import ViewPager from '@react-native-community/viewpager';
hope it helps. feel free for doubts
Upvotes: 1
Reputation: 79
You needs to add @react-native-community/viewpager instead of importing ViewPagerAndroid from react-native.
Upvotes: 0