0

I am trying to use the View Pager on React Native and I am using the reference link for help https://reactnativecode.com/create-viewpager-with-tab-title-dot-indicators/?unapproved=42387&moderation-hash=570c68d8ea5535b832994536ba239b28#comment-42387

When I use the code as it is and run, it gives an error -

ViewPagerAndroid has been removed from React Native. It can now be installed and imported from 'react-native-viewpager' instead of 'react-native'. 

What is that I am missing ?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
akash89
  • 881
  • 3
  • 12
  • 31

2 Answers2

0
yarn add @react-native-community/viewpager

Or

npm -i @react-native-community/viewpager --save

For linking use these command

react-native link @react-native-community/viewpager

In Newer versions of React Native ViewPager is not available, so you have to add it manually

then, you can import it like these

import ViewPager from '@react-native-community/viewpager';
deepak rathod
  • 21
  • 1
  • 3
  • 3
    When possible, please make an effort to provide additional explanation instead of just code. Such answers tend to be more useful as they help members of the community and especially new developers better understand the reasoning of the solution, and can help prevent the need to address follow-up questions. – Rajan May 12 '20 at 05:29
  • 1
    It seems that it is now deprecated. npmjs says: This library is no longer supported. Please use react-native-pager-view instead – Raphael Pinel Apr 01 '21 at 08:04
0

You have to notice:

if your react native version < 0.63 - you need install react-native-tab-view 2.x.x version (the latest in this version is 2.16.0)

if >= 0.63 so install 3.x.x

Maybe this is the reason

Idan
  • 3,604
  • 1
  • 28
  • 33