Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove warning viewPagerAndroid with react native 0.59.5

Tags:

react-native

After upgrading to react native 0.59.5, the app threw the following warning message on simulator:

viewPagerAndroid has been extracted from react-native core...

But there is no import of the viewPagerAndroid in the component file:

import React, { Component} from 'react';
import { SectionList, View, StyleSheet, Text, TouchableOpacity, Platform, AppRegistry } from 'react-native';
import Moment from 'moment';
import DeviceInfo from 'react-native-device-info';
import { GiftedChat } from 'react-native-gifted-chat';

How to remove the warning?

like image 530
user938363 Avatar asked Mar 20 '19 00:03

user938363


1 Answers

As of react-native 0.59.0 ViewPagerAndroid has been deprecated. You can see that in the changelog here.

That means that if you want to use ViewPagerAndroid in the future you will need to install it separately. You can see its repo here

You are probably seeing this warning even though you haven’t explicitly used ViewPagerAndroid because one of the dependencies that you are using used it.

Most commonly react-native-gesture-handler or react-native-tab-view both use ViewPagerHandler.

At the moment the warning is just that, a warning. It isn’t going to cause you any issues until support for ViewPagerAndroid is dropped.

You can suppress the YellowBox warning so it won’t show on device. Note even if you suppress the warning it will always show in the logs.

Import it from react-native

import { YellowBox } from 'react-native';

Then in your App.js

YellowBox.ignoreWarnings(['ViewPagerAndroid']);

You can read more about suppressing warnings here

like image 84
Andrew Avatar answered Nov 16 '22 06:11

Andrew