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:

  1. cd android
  2. ./gradlew clean
  3. cd ..
  4. yarn remove react-native-swiper
  5. yarn add react-native-swiper@nightly
  6. rm -rf node_modules
  7. npm cache clean --force
  8. npm install
  9. react-native run-android

it will work. but if no, please restart system.


I solve it by:

  1. install this module: react-native-community / viewpager

  2. 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.

  3. 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

Tags:

React Native