最佳答案
我有以下呈现方法在我的反应本机代码:
render() {
const {height, width} = Dimensions.get('window');
return (
<View style={styles.container}>
<Image
style={{
height:height,
width:width,
}}
source={require('image!foo')}
resizeMode='cover'
/>
<TouchableHighlight style={styles.button}/>
</View>
);
}
它给了我这个错误:
React.Children.only
预计将接收单个 React 元素的子元素
如果我删除 TouchableHighlight
组件,它工作得很好。如果我删除 Image 组件,它仍然会产生错误。
I can't see why it gives me this error. <View>
should be able to have more than one component inside it for rendering.