react-native onPress binding with an argument

前端 未结 6 2115
予麋鹿
予麋鹿 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:23

    try this

    const onChangeHandler = index => { console.log(index) }
    onPress={onChangeHandler.bind(this, index)}
    

提交回复
热议问题