我使用了react-native-directed-view,但是react-native-directed-view变得没有维护。
我成功地使用UIScrollView
in native native并将变量传递给本机代码。
下面是我的代码的一部分。我用requireNativeComponent
来搭桥。
import {
...
requireNativeComponent
} from 'react-native'
const CounterView = requireNativeComponent("CounterView")
...
render() {
return (
<View style={styles.container}>
<CounterView />
</View>
)
}
但!!!
我不能在swift中使用porps.children
(HOC)。我可以将字符串和整数传递给swift,因为obj-c有字符串和整数类型。
@objc var count: NSSumber = 0
但是obj-c中没有jsx类型
如何用swift创建HOC? react-native-directed-view使用HOC和objective-c。我想快速使用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
您是否将此lib链接到本机代码?我的意思是react-native链接react-native-directed-view。