React Native this2.'function' is not a function

后端 未结 2 630
小鲜肉
小鲜肉 2021-01-23 19:24

I have a problem with my React Native Component.

sayHi = (s) => {
    console.log(\'hey\' + s)
}

renderListItem(item, i) {

    return (
        

        
2条回答
  •  臣服心动
    2021-01-23 19:54

    Just for reference, the bind solution mentioned in the comments by Andrew Li can be accomplished by changing this line

    {list.map(this.renderListItem)}
    

    to this

    {list.map(this.renderListItem.bind(this))}
    

提交回复
热议问题