I have a Item which receives a value from a props value. This value is not set correctly according to react-native error messaging.
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)}) } /> );
}
}
I am wondering why I can't update my value , and what a shadow node is, and how to prevent this in the future?
EDIT: something to do with the value of 'barinterval' being a string but only accepting numbers. (wrong value given?)
The error explains that it expects a variable as integer, and not as a string value.
Example
<BarItem barInterval={'5'} />
is wrong, but <BarItem barInterval={5} />
is correct.
In this case the value marginRight
requires a integer to work, because the variable is used in a stylesheet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With