From e53dcb9ece0be4ad4631db71b1f4fd12d28d6bbc Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Tue, 2 Jul 2024 15:39:23 +0200 Subject: [PATCH] fix(iOS, Paper): possibility of infinite loop when swiping back in nested stack (#2223) ## Description In #2193 I've made a mistake - on Paper, when there is no touch handler held in `_touchHandler` field I've started lookup for touch handler in ancestor chain from `self` -> which leads to infinite loop when swiping back in nested-stack navigation scenario. ## Changes * Started lookup from superview. ## Test code and steps to reproduce `Test2223` 1. Navigate to NestedStack. 2. Navigate to NestedStack details screen. 3. Use swipe gesture to go-back W/o this PR the application will crash hitting infinite loop. Also test that this behaviour remains fixed: * https://github.com/software-mansion/react-native-screens/pull/2131 ## Checklist - [x] Included code example that can be used to test this change - [x] Ensured that CI passes --- apps/test-examples/App.js | 1 + apps/test-examples/src/Test2223.tsx | 88 +++++++++++++++++++++++++++++ ios/utils/UIView+RNSUtility.mm | 2 +- 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 apps/test-examples/src/Test2223.tsx diff --git a/apps/test-examples/App.js b/apps/test-examples/App.js index 825595aafc..781ef96a88 100644 --- a/apps/test-examples/App.js +++ b/apps/test-examples/App.js @@ -103,6 +103,7 @@ import Test2048 from './src/Test2048'; import Test2069 from './src/Test2069'; import Test2118 from './src/Test2118'; import Test2184 from './src/Test2184'; +import Test2223 from './src/Test2223'; import TestScreenAnimation from './src/TestScreenAnimation'; import TestHeader from './src/TestHeader'; diff --git a/apps/test-examples/src/Test2223.tsx b/apps/test-examples/src/Test2223.tsx new file mode 100644 index 0000000000..587fbf38da --- /dev/null +++ b/apps/test-examples/src/Test2223.tsx @@ -0,0 +1,88 @@ +import React from 'react'; +import { View, Text, Button, Pressable, StyleSheet, Alert } from 'react-native'; +import { NavigationContainer, useNavigation } from '@react-navigation/native'; +import { createNativeStackNavigator } from '@react-navigation/native-stack'; + +const Stack = createNativeStackNavigator(); +const NestedStack = createNativeStackNavigator(); + +export default function App() { + return ( + + + + + + + + ); +} + +function NestedStackScreen() { + return ( + + + + + ); +} + +function HomeScreen() { + const navigation = useNavigation(); + return ( + + Home Screen +