【发布时间】:2019-09-07 05:20:08
【问题描述】:
我使用了 react-native-directed-view,但是 react-native-directed-view 变得无人维护。
我成功使用UIScrollView 反应原生并将变量传递给原生代码。
下面是我的代码的一部分。我使用requireNativeComponent 桥接。
import {
...
requireNativeComponent
} from 'react-native'
const CounterView = requireNativeComponent("CounterView")
...
render() {
return (
<View style={styles.container}>
<CounterView />
</View>
)
}
但是!!!
我不能快速使用porps.children(HOC)。
我可以将字符串和整数传递给 swift,因为 obj-c 具有字符串和整数类型。
@objc var count: NSSumber = 0
但是obj-c中没有jsx类型
如何快速创建 HOC? react-native-directed-view 使用了带有 Objective-c 的 HOC。 我想快速使用 HOC。
我知道在 swift 中使用 RCTRootView 可以在 swift 中使用 jsx。
我想知道如何通过 JSX 以及如何将它与RCTRootView 一起使用。
理想的代码如下。
import {View, Text, requireNativeComponent}
const UIscrollView = requireNativeComponent("UIScrollView")
// HOC with native code
const App = () => (
<UIScrollView height={100} width={100}>
<View>
<Text>lol</Text>
</View>
<UIScrollView>
)
export default App
【问题讨论】:
标签: swift react-native bridge