Issue
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?)
Solution
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.
Answered By - Jasper Lankhorst
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.