我有一个从 Prop 值接收值的项目。
根据 react-native 错误消息,此值未正确设置。
export default class BarItem extends Component {
constructor (props) {
super(props);
}
propTypes : {
color: PropTypes.string,
barInterval: PropTypes.number,
};
const {color, barInterval} = this.props;
render () {
const baseStyle = {
backgroundColor: color,
marginRight: barInterval
};
return ( <View style={Object.assign({}, baseStyle, {height: (empty * unitHeight)}) } /> );
}
}
我想知道为什么我不能更新我的值,影子节点是什么,以及将来如何防止这种情况发生?
编辑:与“barinterval”的值有关,它是一个字符串,但只接受数字。 (给出错误的值?)
最佳答案
该错误解释说它期望一个变量为整数,而不是字符串值。
示例 <BarItem barInterval={'5'} />
是错误的,但是 <BarItem barInterval={5} />
是正确的。
在这种情况下,值 marginRight
需要一个整数才能工作,因为该变量在样式表中使用。
关于react-native - 更新类型为 : RCTView 的阴影节点中的属性 'X' 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37483753/