不变违规:ViewPagerAndroid 已从 React Native 中删除。'react-native-viewpager' 而不是 'react-native'

Man*_*yam 8 react-native

当我使用这个例子在我的应用程序上实现 Image-slider 时,我遇到了这个错误。

import React,{Component} from 'react'
    import {View,Text,TouchableOpacity, ViewPagerAndroid} from 'react-native'
    import Infoslider from 'react-native-infoslider'
     export default class example extends Component {
      constructor(props) {
        super(props);
        this.state = {
          data:[
              {
              title:"Hello World", 
              text:"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard",
              image: require('../Images/Group.png')}
             ]
        };
      }
      render() {
        return (
         <Infoslider 
            data={this.state.data} />
        );
      }
    }
Run Code Online (Sandbox Code Playgroud)

像这样的错误

小智 8

您应该将react-native-swiper模块更新为nightly。然后,npm 清除缓存。
请遵循以下步骤:

  1. 安卓系统
  2. ./gradlew 干净
  3. 光盘 ..
  4. 纱线移除反应本机刷卡器
  5. 纱线添加react-native-swiper@nightly
  6. rm -rf 节点模块
  7. npm 缓存清理 --force
  8. npm 安装
  9. 反应本机运行 Android

它会起作用的。但如果没有,请重新启动系统。