Skip to content

Conversation

m-bert
Copy link
Contributor

@m-bert m-bert commented Apr 7, 2025

Description

Apparently faulty logic in ReanimatedSwipeable makes onSwipeableClose and onSwipeableWillClose callbacks being triggered right after opening swipeable. This PR fixes that behavior.

Fixes #3475

Test plan

Tested on the following code:
import React from 'react';
import { View, Text } from 'react-native';
import Swipeable from 'react-native-gesture-handler/ReanimatedSwipeable';

export default function Example() {
  return (
    <Swipeable
      renderLeftActions={() => {
        return (
          <View style={{ height: 80, width: 80, backgroundColor: 'yellow' }}>
            <Text>Left</Text>
          </View>
        );
      }}
      renderRightActions={() => {
        return (
          <View style={{ height: 80, width: 80, backgroundColor: 'magenta' }}>
            <Text>Right</Text>
          </View>
        );
      }}
      onSwipeableWillClose={() => console.log('Will close')}>
      <View
        style={{
          height: 80,
          backgroundColor: 'blue',
        }}
      />
    </Swipeable>
  );
}

@m-bert m-bert requested a review from latekvo April 7, 2025 12:01
@m-bert m-bert requested review from latekvo and j-piasecki May 27, 2025 16:03
@m-bert m-bert merged commit 1415d55 into main May 28, 2025
1 check passed
@m-bert m-bert deleted the @mbert/fix-swipeable-close-called-on-open branch May 28, 2025 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ReanimatedSwipeable: onSwipeableClose is triggered when onSwipeableOpen is not set
3 participants