software-mansion / react-native-gesture-handler

Declarative API exposing platform native touch and gesture system to React Native.
https://docs.swmansion.com/react-native-gesture-handler/
MIT License
6.13k stars 982 forks source link

Change `onPress` argument in buttons #3006

Closed m-bert closed 4 months ago

m-bert commented 4 months ago

Description

This PR changes argument passed into onPress callback in our Buttons. Previous one was always false because of this code:

const active = pointerInside && state === State.ACTIVE;
...
if (
  ...
  oldState === State.ACTIVE &&
  ...
) {
  this.props.onPress(active);
}

callback was executed when state was END, so active was false at this point.

Test plan

Test code ```tsx import React from 'react'; import { StyleSheet, View } from 'react-native'; import { RectButton } from 'react-native-gesture-handler'; export default function EmptyExample() { return ( ); } const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', justifyContent: 'space-around', }, button: { width: 300, height: 100, borderRadius: 25, backgroundColor: 'crimson', }, }); ```