android - Button wouldn't respond until I press it several times in React Native -


i experiencing weird bug in react native android project.

there media controller page custom audio player implemented (with play/pause, next, previous buttons etc), , works fine on android simulators, when try click on buttons of on real device, not respond until press 10 times.

several causes can think of:

  • the whole page responds pan gesture, on simulator, click event recognized click, on device, recognizes pan gesture.

  • around 1,000 warnings of warning: manually calling react.proptypes validation function... (of solution might this answer), , play performance of app.  (this issue fixed, still happens)

  • there couple of libraries used in app only implemented ios such react-native-streamingkit , react-native-mpremotecommandcenter, , 1 of them might causing issue.

am getting around right? other reason causing issue?

i fixed bug - reason #1 among ones listed out.

the onmoveshouldsetpanrespondercapture() function in 1 of panresponders contained code:

onmoveshouldsetpanrespondercapture: (evt, gesturestate) => {     return dx != 0 && dy != 0 && this._canpan; } 

in other words, code setting threshold of distinguishing between tap gesture , pan gesture zero!

i changed follows , working beautifully:

onmoveshouldsetpanrespondercapture: (evt, gesturestate) => {     return (math.abs(gesturestate.dx) > 5 || math.abs(gesturestate.dy) > 5) && this._canpan; } 

set threshold 10px if like.


Comments