Reactjs 子组件的道具类型
比方说,我想做一件像这样简单的事情Reactjs 子组件的道具类型,reactjs,react-native,Reactjs,React Native,比方说,我想做一件像这样简单的事情 <View style={[styles.container, { backgroundColor, bottom }]}> {this.props.children} </View> {this.props.children} 在这里,什么样的道具适合儿童 其中子级可以是由scrollView、TextInput、Text等组成的本地组件 <MyComponent> <View> &
<View style={[styles.container, { backgroundColor, bottom }]}>
{this.props.children}
</View>
{this.props.children}
在这里,什么样的道具适合儿童
其中子级可以是由scrollView、TextInput、Text等组成的本地组件
<MyComponent>
<View>
<Text> Could be text </Text>
</View>
</MyComponent>
可以是文本
我一直用于儿童的是:
static propTypes = {
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node), //as you can render an array of elements
PropTypes.element //for a single component/element
]).isRequired
}