React native:Native模块不能为null

时间:2018-08-10 07:40:57

标签: ios reactjs react-native

在iOS中构建项目时,按照该特定顺序出现以下错误:

No component found for view with name "RCTRawText"

No component found for view with name "RCTText"

Unhandled JS Exception: Requiring module "Linking", which threw an exception: Invariant Violation: Native module cannot be null.

ExceptionsManager.js:73 Unhandled JS Exception: TypeError: Cannot read property 'addEventListener' of undefined

This error is located at:
    in NavigationContainer (at index.js:13)
    in Provider (at index.js:12)
    in ReactHome (at renderApplication.js:35)
    in RCTView (at View.js:113)
    in View (at AppContainer.js:102)
    in RCTView (at View.js:113)
    in View (at AppContainer.js:122)
    in AppContainer (at renderApplication.js:34)

我发现这篇文章可以提供帮助,但错误仍然存​​在。

预先感谢

2 个答案:

答案 0 :(得分:0)

您必须从NavigationContainer中的react-native导入链接模块

答案 1 :(得分:0)

在ios / Podfile文件中添加RCTText为我解决了此错误:

target 'YourProject' do

  pod 'React', :path => '../node_modules/react-native/', subspecs: [

    ...,

    'RCTText'
  ]

  ...
end

此错误可能是由于反应本机版本早于0.60.0,因为在更高版本中,它会在升级时自动添加。