Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-Native : onPanResponderGrant Vs onPanResponderStart

Tags:

react-native

PanResponder.create() has many callbacks and two of them are onPanResponderGrant and onPanResponderStart. Both callbacks getting triggered as soon as screen is touched.react-native official documentation doesn't have much information about these callbacks.

Can anybody let me know the difference between these two callbacks and when to use which one?

like image 331
Mighty Avatar asked Feb 02 '19 12:02

Mighty


1 Answers

onPanResponderGrant is called when a gesture is "started" while onPanResponderStart is called on additional gesture events.

For example, if you were to place one finger on the screen, onPanResponderGrant would fire, then, if a second finger is placed without removing the first onPanResponderStart would fire.

You can view some logic regarding this in the RN repo: https://github.com/facebook/react-native/blob/master/Libraries/Interaction/PanResponder.js

like image 72
JavanPoirier Avatar answered Oct 26 '22 00:10

JavanPoirier