最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - React Native equivalent to mousedown - Stack Overflow

programmeradmin1浏览0评论

If I'm making a website, I can use a mousedown event to trigger something when the mouse button is pressed (and not yet released).

In React Native, I've got a TouchableHighlight and can register an onPress callback, but this only triggers when I release my finger from the button.

Is there a way to trigger as soon as a finger touches a button, rather than only when the finger is released?

If I'm making a website, I can use a mousedown event to trigger something when the mouse button is pressed (and not yet released).

In React Native, I've got a TouchableHighlight and can register an onPress callback, but this only triggers when I release my finger from the button.

Is there a way to trigger as soon as a finger touches a button, rather than only when the finger is released?

Share Improve this question asked Jul 8, 2017 at 9:19 JackJack 2,2336 gold badges31 silver badges45 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

Solved shortly afterwards! The onResponderStart prop is what I needed. This isn't actually documented in the gesture responder system docs, but it seems to work for me!

<View onStartShouldSetResponder={() => true}
      onResponderStart={calledWhenTheTouchStarts}>

    <Text>Press Me!</Text>

</View>
发布评论

评论列表(0)

  1. 暂无评论