react-native: undefined is not an object (evaluting 'validAttributes.style')

here is the code :

const style = {
  marginTop: 11.8,
  marginLeft: marginLeft,
  marginRight: marginRight,
  width: width
};
/// ...       
itemviews.push(
  <TouchableHighlight 
    underlayColor="#00000000" 
    key={i} 
    style={style}
    onPress={this.onPressunCoverList.bind(this, moneyDict.gameId, moneyDict.userName)}>
      <Image 
        style={[styles.noredimageStyle, {width: width}]} 
        source={require('../../image/noRedPacket.png')}/>
  </TouchableHighlight>
)

If i click the Image on a android device, it will show this: “undefined is not an object (evaluting ‘validAttributes.style’)”, but iOS device is ok.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 20 (8 by maintainers)

Most upvoted comments

Finally I founded case, for reproduce tis issue.

This construction will cause an error on Android:

<TouchableHighlight onPress={this.onPressPicture.bind(this, image)}>
      <Image>
          <View>
          </View>           
      </Image>
</TouchableHighlight>

But, This construction works well on both:

<TouchableOpacity onPress={this.onPressPicture.bind(this, image)}>
      <Image>
          <View>
          </View>           
      </Image>
</TouchableOpacity>

Question, why TouchableHighlight cause an error?