在UIManager中找不到“不变违规:requireNativeComponent:\“ SwipeView \”

时间:2019-08-22 19:17:07

标签: react-native

当我登录到我的React Native应用程序并经历了从所有端点加载数据的过程时,它最终崩溃并出现以下错误:

  

不变违规:requireNativeComponent:未找到“ SwipeView”   在UIManager中

{
  "message": "Invariant Violation: requireNativeComponent: \"SwipeView\" was not found in the UIManager.\n\nThis error is located at:\n    in SwipeView (at SwipeView.js:14)\n    in SwipeView (at SwippableCard.js:6)\n    in SwippableCard (at Main.js:173)\n    in RCTView (at View.js:35)\n    in View (at VirtualizedList.js:1770)\n    in CellRenderer (at VirtualizedList.js:688)\n    in RCTScrollContentView (at ScrollView.js:1007)\n    in RCTScrollView (at ScrollView.js:1120)\n    in ScrollView (at VirtualizedList.js:1064)\n    in VirtualizedList (at FlatList.js:634)\n    in FlatList (at Main.js:348)\n    in RCTView (at View.js:35)\n    in View (at Main.js:347)\n    in ActivityFeed (created by Connect(ActivityFeed))\n    in Connect(ActivityFeed) (at SceneView.js:17)\n    in SceneView (at CardStack.js:466)\n    in RCTView (at View.js:35)\n    in View (at createAnimatedComponent.js:151)\n    in AnimatedComponent (at Card.js:12)\n    in Card (at PointerEventsContainer.js:39)\n    in Container (at CardStack.js:498)\n    in RCTView (at View.js:35)\n    in View (at CardStack.js:414)\n    in RCTView (at View.js:35)\n    in View (at CardStack.js:413)\n    in CardStack (at CardStackTransitioner.js:67)\n    in RCTView (at View.js:35)\n    in View (at Transitioner.js:142)\n    in Transitioner (at CardStackTransitioner.js:19)\n    in CardStackTransitioner (at StackNavigator.js:41)\n    in Unknown (at createNavigator.js:13)\n    in Navigator (at createNavigationContainer.js:226)\n    in NavigationContainer (at SceneView.js:17)\n    in SceneView (at DrawerScreen.js:21)\n    in DrawerScreen (at withCachedChildNavigation.js:69)\n    in withCachedChildNavigation(DrawerScreen) (at DrawerNavigator.js:71)\n    in Unknown (at createNavigator.js:13)\n    in Navigator (at DrawerView.js:178)\n    in RCTView (at View.js:35)\n    in View (at createAnimatedComponent.js:151)\n    in AnimatedComponent (created by DrawerLayout)\n    in RCTView (at View.js:35)\n    in View (created by DrawerLayout)\n    in DrawerLayout (at DrawerView.js:158)\n    in DrawerView (at DrawerNavigator.js:88)\n    in Unknown (at createNavigator.js:13)\n    in Navigator (at createNavigationContainer.js:226)\n    in NavigationContainer (at SceneView.js:17)\n    in SceneView (at CardStack.js:466)\n    in RCTView (at View.js:35)\n    in View (at createAnimatedComponent.js:151)\n    in AnimatedComponent (at Card.js:12)\n    in Card (at PointerEventsContainer.js:39)\n    in Container (at CardStack.js:498)\n    in RCTView (at View.js:35)\n    in View (at CardStack.js:414)\n    in RCTView (at View.js:35)\n    in View (at CardStack.js:413)\n    in CardStack (at CardStackTransitioner.js:67)\n    in RCTView (at View.js:35)\n    in View (at Transitioner.js:142)\n    in Transitioner (at CardStackTransitioner.js:19)\n    in CardStackTransitioner (at StackNavigator.js:41)\n    in Unknown (at createNavigator.js:13)\n    in Navigator (at createNavigationContainer.js:226)\n    in NavigationContainer (at RootNavigation.js:207)\n    in RootNavigation (created by Connect(RootNavigation))\n    in Connect(RootNavigation) (at App.js:249)\n    in RCTView (at View.js:35)\n    in View (at App.js:247)\n    in Provider (at App.js:246)\n    in NFIBEngage (at renderApplication.js:40)\n    in RCTView (at View.js:35)\n    in View (at AppContainer.js:98)\n    in RCTView (at View.js:35)\n    in View (at AppContainer.js:115)\n    in AppContainer (at renderApplication.js:39)",
  "stack": []
}

我尝试运行pod install并收到以下警告:

[!] use_native_modules! skipped the react-native dependency 'react-native-swipe-view'. No podspec file was found.
    - Check to see if there is an updated version that contains the necessary podspec file
    - Contact the library maintainers or send them a PR to add a podspec. The react-native-webview podspec is a good example of a package.json driven podspec.
    See https://github.com/react-native-community/react-native-webview/blob/master/react-native-webview.podspec
    - If necessary, you can disable autolinking for the dependency and link it manually. See
    https://github.com/react-native-community/cli/blob/master/docs/autolinking.md#how-can-i-disable-autolinking-for-unsupported-library

我尝试通过创建react-native.config.js文件来应用最后一点。

然后我通过react-native link react-native-swipe-view手动链接了库,但这没用。

此库正在SwippableCard.js中使用:

import React from "react";
import PropTypes from "prop-types";
import { SwipeView } from "react-native-swipe-view";

const SwippableCard = props => (
  <SwipeView
    changeOpacity={true}
    removeViewOnSwipedOut={true}
    onSwipedOut={props.onSwipedOut}
  >
    {props.children}
  </SwipeView>
);

SwippableCard.propTypes = {
  children: PropTypes.any.isRequired,
  onSwipedOut: PropTypes.func
};

export { SwippableCard };

在Reactotron中,它抛出上述错误大约9次,我相信它的SwippableCard组件试图使用来自以下状态的状态重新渲染:

api/1.0/activities?depth=full&types=BALLOT,SURVEY,MICRO,ARTICLE,EVENT,NOTIFICATION,TOPIC,INVOLVEMENT

我能够在android上使用它,但是我不知道为什么在ios上不能使用它。我需要一些非常了解XCode配置以及可能出问题的人的帮助。

我现在在Android平台上可以正常使用react-native-swipe-view,但是在应用程序级别上,我仍然遇到ios的错误。

我不认为这是podspec的问题,因为在XCode原始设置上它可以正常工作。

1 个答案:

答案 0 :(得分:0)

react-native link react-native-swipe-view

这将解决问题。这是因为指定的程序包未链接。