react-native onPress binding with an argument

前端 未结 6 2116
予麋鹿
予麋鹿 2020-12-24 04:42

The desired behaviour is to pass an argument (text) to the onClick handler to console.log it but it seems that I\'m doing something wrong with the syntax.

If I leave

6条回答
  •  孤城傲影
    2020-12-24 05:39

    You should just pass one fat arrow function before calling the function.

    onPress= {()=> this.handlePress(param)}
    

提交回复
热议问题