Invariant Violation: ViewPagerAndroid has been removed from React Native.'react-native-viewpager' instead of 'react-native'
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.
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.
- in the same file, go to the return function, and change ViewPagerAndroid to ViewPager
This works for me
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