React Native onPress being called automatically

前端 未结 5 1384
悲&欢浪女
悲&欢浪女 2020-12-12 20:20

I am having trouble with react-native onPress Feature. The onPress should only work when it is actually been triggered by a touch event (i suppose) , that is when i press th

5条回答
  •  Happy的楠姐
    2020-12-12 20:53

    The reason for such behaviour is on every render, reference to the function is created.

    So, to avoid that, use bind function OR arrow function to call on onPress

提交回复
热议问题