oblador / react-native-animatable

Standard set of easy to use animations and declarative transitions for React Native
MIT License
9.81k stars 702 forks source link

onPress is not working with custom button component #327

Open sushmitg opened 4 years ago

sushmitg commented 4 years ago
const DoneButton = ({onClick, animation, showDoneBtn}) => {
    return (
      <Animatable.View animation={animation} duration={150}>
          <ThemeButton
            buttonStyle={{...styles.doneBtnStyle, opacity: showDoneBtn ? 1 : 0}}
            icon={<Icon name="arrow-forward" color="#fff" size={24} />}
            onPress={onClick}
          />
      </Animatable.View>
    );
  };

my onClick function is not being called since I have wrapped the button in

t1gu1 commented 3 years ago

Same problem here.

The workaround I found is to have animation inside the element with an onPress.

<ThemeButton onPress={onClick}>
    <Animatable.View animation={animation} duration={150}>
        <Text>My text</Text>
    </Animatable.View>
<ThemeButton>