Css React本机升级后出现黄色框错误/警告
我最近将我的项目从React Native 0.15升级到了0.20。我想这是一种飞跃,我对这些黄框警告还很陌生。现在我得到了如下两个警告 警告一:Css React本机升级后出现黄色框错误/警告,css,react-native,Css,React Native,我最近将我的项目从React Native 0.15升级到了0.20。我想这是一种飞跃,我对这些黄框警告还很陌生。现在我得到了如下两个警告 警告一: container: { overflow: 'hidden', width: Dimensions.get('window').width, flexDirection: 'row', alignItems: 'center', backgroundColor: 'rgba(255, 255, 255, 0
container: {
overflow: 'hidden',
width: Dimensions.get('window').width,
flexDirection: 'row',
alignItems: 'center',
backgroundColor: 'rgba(255, 255, 255, 0.0)',
shadowColor: '#000000',
shadowOpacity: 1,
shadowRadius: 20,
shadowOffset: {width: 0, height: -5},
justifyContent: 'center'
}
renderItem: function (item) {
var Dimensions = require('Dimensions');
return (
<View style={styles.mainContainer}>
<TouchableHighlight underlayColor="rgba(0,0,0,0)" style={styles.buttonFill}
onPress={this.categoryPressed.bind(this, item.categoryId, item.name)}>
<View style={styles.container}>
<KenBurnsImage tension={6} friction={50} imageWidth={Dimensions.get('window').width} imageHeight={Dimensions.get('window').height / 100 * 30} sourceUri={{uri: item.image}} placeholderSource={{uri: './images/placeholder.jpg'}}/>
<View>
<LinearGradient
colors={[processColor('rgba(255, 255, 255, 0.0)'), processColor('rgba(0,0,0,0)'), processColor('rgba(0,0,0,0.7)')]}
style={styles.linearGradient}>
<View style={styles.allContent}>
<View style={styles.imageRowContainer}>
<View style={styles.nameContainer}>
<Text style={styles.textMain}>{item.name}</Text>
</View>
{this._renderItemCountSection(item.itemsCount)}
<View style={styles.continueContainer}>
<Text style={styles.textArrow}></Text>
</View>
</View>
</View>
</LinearGradient>
</View>
</View>
</TouchableHighlight>
</View>
);
}
警告:React.createElement:类型不应为null,未定义,
布尔值,或数字。它应该是字符串(对于DOM元素)或
ReactClass(用于复合组件)。检查的渲染方法
项目视图页面
警告二:
container: {
overflow: 'hidden',
width: Dimensions.get('window').width,
flexDirection: 'row',
alignItems: 'center',
backgroundColor: 'rgba(255, 255, 255, 0.0)',
shadowColor: '#000000',
shadowOpacity: 1,
shadowRadius: 20,
shadowOffset: {width: 0, height: -5},
justifyContent: 'center'
}
renderItem: function (item) {
var Dimensions = require('Dimensions');
return (
<View style={styles.mainContainer}>
<TouchableHighlight underlayColor="rgba(0,0,0,0)" style={styles.buttonFill}
onPress={this.categoryPressed.bind(this, item.categoryId, item.name)}>
<View style={styles.container}>
<KenBurnsImage tension={6} friction={50} imageWidth={Dimensions.get('window').width} imageHeight={Dimensions.get('window').height / 100 * 30} sourceUri={{uri: item.image}} placeholderSource={{uri: './images/placeholder.jpg'}}/>
<View>
<LinearGradient
colors={[processColor('rgba(255, 255, 255, 0.0)'), processColor('rgba(0,0,0,0)'), processColor('rgba(0,0,0,0.7)')]}
style={styles.linearGradient}>
<View style={styles.allContent}>
<View style={styles.imageRowContainer}>
<View style={styles.nameContainer}>
<Text style={styles.textMain}>{item.name}</Text>
</View>
{this._renderItemCountSection(item.itemsCount)}
<View style={styles.continueContainer}>
<Text style={styles.textArrow}></Text>
</View>
</View>
</View>
</LinearGradient>
</View>
</View>
</TouchableHighlight>
</View>
);
}
RCTView类型的视图#2359具有阴影集,但无法计算
有效地阴影。考虑设置背景颜色来修复这个问题,
或者将阴影应用于更具体的组件
发现警告一是由于使用const Radio=require('react-native-simple-Radio-button')代码>而不是从“react native simple单选按钮”导入单选按钮代码>。更改完成后,警告一号就消失了
对于警告二,它所发送的页面具有使用阴影的位置
样式代码:
container: {
overflow: 'hidden',
width: Dimensions.get('window').width,
flexDirection: 'row',
alignItems: 'center',
backgroundColor: 'rgba(255, 255, 255, 0.0)',
shadowColor: '#000000',
shadowOpacity: 1,
shadowRadius: 20,
shadowOffset: {width: 0, height: -5},
justifyContent: 'center'
}
renderItem: function (item) {
var Dimensions = require('Dimensions');
return (
<View style={styles.mainContainer}>
<TouchableHighlight underlayColor="rgba(0,0,0,0)" style={styles.buttonFill}
onPress={this.categoryPressed.bind(this, item.categoryId, item.name)}>
<View style={styles.container}>
<KenBurnsImage tension={6} friction={50} imageWidth={Dimensions.get('window').width} imageHeight={Dimensions.get('window').height / 100 * 30} sourceUri={{uri: item.image}} placeholderSource={{uri: './images/placeholder.jpg'}}/>
<View>
<LinearGradient
colors={[processColor('rgba(255, 255, 255, 0.0)'), processColor('rgba(0,0,0,0)'), processColor('rgba(0,0,0,0.7)')]}
style={styles.linearGradient}>
<View style={styles.allContent}>
<View style={styles.imageRowContainer}>
<View style={styles.nameContainer}>
<Text style={styles.textMain}>{item.name}</Text>
</View>
{this._renderItemCountSection(item.itemsCount)}
<View style={styles.continueContainer}>
<Text style={styles.textArrow}></Text>
</View>
</View>
</View>
</LinearGradient>
</View>
</View>
</TouchableHighlight>
</View>
);
}
代码:
container: {
overflow: 'hidden',
width: Dimensions.get('window').width,
flexDirection: 'row',
alignItems: 'center',
backgroundColor: 'rgba(255, 255, 255, 0.0)',
shadowColor: '#000000',
shadowOpacity: 1,
shadowRadius: 20,
shadowOffset: {width: 0, height: -5},
justifyContent: 'center'
}
renderItem: function (item) {
var Dimensions = require('Dimensions');
return (
<View style={styles.mainContainer}>
<TouchableHighlight underlayColor="rgba(0,0,0,0)" style={styles.buttonFill}
onPress={this.categoryPressed.bind(this, item.categoryId, item.name)}>
<View style={styles.container}>
<KenBurnsImage tension={6} friction={50} imageWidth={Dimensions.get('window').width} imageHeight={Dimensions.get('window').height / 100 * 30} sourceUri={{uri: item.image}} placeholderSource={{uri: './images/placeholder.jpg'}}/>
<View>
<LinearGradient
colors={[processColor('rgba(255, 255, 255, 0.0)'), processColor('rgba(0,0,0,0)'), processColor('rgba(0,0,0,0.7)')]}
style={styles.linearGradient}>
<View style={styles.allContent}>
<View style={styles.imageRowContainer}>
<View style={styles.nameContainer}>
<Text style={styles.textMain}>{item.name}</Text>
</View>
{this._renderItemCountSection(item.itemsCount)}
<View style={styles.continueContainer}>
<Text style={styles.textArrow}></Text>
</View>
</View>
</View>
</LinearGradient>
</View>
</View>
</TouchableHighlight>
</View>
);
}
renderItem:函数(项){
变量维度=要求(“维度”);
返回(
{item.name}
{this.\u renderitemmcountsection(item.itemsunt)}
;
);
}
renderItem
函数正在从列表视图中呈现项目
正如代码所述,它已经有了背景色。那么,为什么会有这样的警告呢?解决办法是什么?提前感谢。这是因为您正在将背景色设置为透明rgba(255、255、255、0.0)
。这是非常低效的。您可以在这个提交日志中阅读所有这些内容
警告二
在我的例子中,我删除了阴影不透明度,将其添加到阴影颜色并使用RGBA值
shadowColor: 'rgba(0,0,0, 0.1)'
我复制了你的例子,它没有给我一个错误。你能给我们更多的代码吗?你能不能也包括你正在应用这种风格的JSX?以及它的父JSX和style@G.Hamaide添加了使用样式的JSX代码。@AakashSigdel添加了JSX代码。好的,谢谢。不过,我这里没有提出警告。如果删除线性渐变,警告还在吗?谢谢。这是根本原因。如何在边界半径上有阴影,溢出:隐藏?现在我不得不为阴影添加另一层容器,因为overflow:hidden
将剪裁阴影。顺便说一句,这将导致此错误,因为容器没有任何背景颜色来解决我的问题,在我的情况下,将背景颜色添加到视图中。谢谢