3

I am using expo ^40.0.0.

I am trying to get react-native-gesture-handler components to work in a <Modal> from react-native in Android. I followed docs here - https://docs.swmansion.com/react-native-gesture-handler/docs/#for-library-authors

It stays to wrap in <GestureHandlerRootView>, I did this but it doesn't fix the issue.

I created a snack demo of issue - https://snack.expo.io/@noitidart/frisky-carrot

Here you see a "Tapped here count: 0". Please try tapping it, you will see it doesn't increment the counter.

You will see a "RN BUTTON" this works but it is not from react-native-gesture-handler.

Here is my code from the snack:

import * as React from 'react';
import { Text, View, Modal, Button as RNButton } from 'react-native';
import {
  BaseButton,
  GestureHandlerRootView
} from 'react-native-gesture-handler';


export default function App() {
  return (
          <Modal animationType="slide" transparent={false}>
        <Example />
      </Modal>
  );
}

const Example = function () {
  const [cnt, setCnt] = React.useState(0);
  return (
    <View style={{ justifyContent: 'center', flex: 1 }}>
      <RNButton title="rn button" onPress={() => alert('hi')} />
      <GestureHandlerRootView>
        <BaseButton
          onPress={() => {
            // alert('pressed');
            setCnt(cnt + 1);
          }}
        >
          <View style={{ backgroundColor: 'steelblue', height: 100 }}>
            <Text>Tapped here count: {cnt}</Text>
          </View>
        </BaseButton>
      </GestureHandlerRootView>
    </View>
  );
};
Noitidart
  • 35,443
  • 37
  • 154
  • 323
  • Hi, could you have overcome this? – Mehmet Kaplan Dec 28 '21 at 05:24
  • 1
    Hey I posted solution here - https://github.com/expo/expo/issues/12499 – Noitidart Dec 28 '21 at 18:15
  • 1
    Thanks @Noitidart. I had found that post after I asked the question. In my case, the problem was not a modal scenario but usage with absolute positioning. I issued this bug https://github.com/software-mansion/react-native-gesture-handler/issues/1787 and found a workaround as stated in the bug. Anyhow, thanks a lot. – Mehmet Kaplan Dec 29 '21 at 09:29

0 Answers0