Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while updating property 'X' in shadow node of type: RCTView

Tags:

react-native

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?)

like image 248
Jasper Lankhorst Avatar asked May 27 '16 12:05

Jasper Lankhorst


1 Answers

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.

like image 59
Jasper Lankhorst Avatar answered Oct 06 '22 12:10

Jasper Lankhorst