首页 > 解决方案 > 原生模块:{ Component } = NativeModules 和 requireNativeComponent('Component') 之间的区别

问题描述

我有点困惑。我刚刚完成了这两个教程,开始在 Swift 中编写我自己的原生模块:

https://teabreak.e-spres-oh.com/swift-in-react-native-the-ultimate-guide-part-1-modules-9bb8d054db03

https://teabreak.e-spres-oh.com/swift-in-react-native-the-ultimate-guide-part-2-ui-components-907767123d9e

第一个是无视图模块,导入如下:

const { Module } = NativeModules;

第二个是带有视图的原生组件,导入方式如下:

const ImageBlendView = requireNativeComponent('ImageBlendView')

这些在某种程度上是否可以互换,或者 UI 视图的存在或不存在是否会产生根本性的差异?

标签: react-native

解决方案


推荐阅读