如何从其他容器构造容器。 例如:
容器C - 负责不同风格C的A + B.
代码:
class ContainerA extends Component{
render() {
return (
<ComponentA/>
)
}
}
class ContainerB extends Component{
render() {
return (
<ComponentB/>
)
}
}
class ContainerC extends Component{
render() {
return (
<ContainerA/>
<ContainerB/>
)
}
}
答案 0 :(得分:1)
如果要在React Native中对组件进行分组,可以使用View
import React, { Component } from 'react'
import { View } from 'react-native'
import ContainerA from './ContainerA'
import ContainerB from './ContainerB'
class ContainerC extends Component{
render() {
return (
<View style={styles.containerStyle}>
<ContainerA/>
<ContainerB/>
</View>
)
}
}
const styles = {
containerStyle = {
// ...
}
}