使用React Native 0.59.5删除警告viewPagerAndroid

use*_*363 6 react-native

升级到后react native 0.59.5,该应用在模拟器上引发了以下警告消息:

viewPagerAndroid has been extracted from react-native core...
Run Code Online (Sandbox Code Playgroud)

但是viewPagerAndroid在组件文件中没有导入:

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';
Run Code Online (Sandbox Code Playgroud)

如何删除警告?

And*_*rew 8

从本机0.59.0开始,不推荐使用ViewPagerAndroid。您可以在此处的更改日志中看到

这意味着,如果您以后想使用ViewPagerAndroid,则需要单独安装。你可以在这里看到它的回购

即使您没有显式使用ViewPagerAndroid,您也可能会看到此警告,因为所使用的依赖项之一已使用它。

最常见的react-native-gesture-handlerreact-native-tab-view都使用ViewPagerHandler。

目前,警告仅仅是警告。在放弃对ViewPagerAndroid的支持之前,它不会引起任何问题。

您可以禁止YellowBox警告,以便它不会在设备上显示。请注意,即使您取消显示警告,警告也将始终显示在日志中。

从本机导入

import { YellowBox } from 'react-native';
Run Code Online (Sandbox Code Playgroud)

然后在你的 App.js

YellowBox.ignoreWarnings(['ViewPagerAndroid']);
Run Code Online (Sandbox Code Playgroud)

您可以在此处阅读更多有关抑制警告的信息