Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 子组件的道具类型_Reactjs_React Native - Fatal编程技术网

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
}