diff --git a/TestsExample/App.js b/TestsExample/App.js
index c4b499641d..9c1e0c5907 100644
--- a/TestsExample/App.js
+++ b/TestsExample/App.js
@@ -87,6 +87,7 @@ import Test1646 from './src/Test1646';
import Test1649 from './src/Test1649';
import Test1683 from './src/Test1683';
import Test1726 from './src/Test1726';
+import Test1791 from './src/Test1791';
enableFreeze(true);
diff --git a/TestsExample/src/Test1791.tsx b/TestsExample/src/Test1791.tsx
new file mode 100644
index 0000000000..0efbf58036
--- /dev/null
+++ b/TestsExample/src/Test1791.tsx
@@ -0,0 +1,63 @@
+import {NavigationContainer} from '@react-navigation/native';
+
+import {createNativeStackNavigator} from '@react-navigation/native-stack';
+
+import React from 'react';
+import {Button, View} from 'react-native';
+
+const Stack = createNativeStackNavigator();
+
+const Screen1 = ({navigation}) => (
+
+
+);
+
+const Screen2 = ({navigation}) => (
+
+
+);
+
+const Screen3 = ({navigation}) => (
+
+
+);
+
+const Screen4 = () => ;
+
+const App = () => {
+ return (
+
+
+
+
+
+
+
+
+ );
+};
+
+export default App;
diff --git a/src/index.native.tsx b/src/index.native.tsx
index 24c81394bc..99601241e5 100644
--- a/src/index.native.tsx
+++ b/src/index.native.tsx
@@ -34,6 +34,7 @@ import {
} from './types';
import {
isSearchBarAvailableForCurrentPlatform,
+ isNewBackTitleImplementation,
executeNativeBackPress,
} from './utils';
@@ -592,5 +593,6 @@ module.exports = {
useTransitionProgress,
isSearchBarAvailableForCurrentPlatform,
+ isNewBackTitleImplementation,
executeNativeBackPress,
};
diff --git a/src/index.tsx b/src/index.tsx
index 4d432e7030..9e4e264fd9 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -13,6 +13,7 @@ export * from './types';
export { default as useTransitionProgress } from './useTransitionProgress';
export {
isSearchBarAvailableForCurrentPlatform,
+ isNewBackTitleImplementation,
executeNativeBackPress,
} from './utils';
diff --git a/src/utils.ts b/src/utils.ts
index 56a34d399c..5ef2cfce06 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -10,3 +10,9 @@ export function executeNativeBackPress() {
BackHandler.exitApp();
return true;
}
+
+// Because of a bug introduced in https://github.com/software-mansion/react-native-screens/pull/1646
+// react-native-screens v3.21 changed how header's backTitle handles whitespace strings in https://github.com/software-mansion/react-native-screens/pull/1726
+// To allow for backwards compatibility in @react-navigation/native-stack we need a way to check if this version or newer is used.
+// See https://github.com/react-navigation/react-navigation/pull/11423 for more context.
+export const isNewBackTitleImplementation = true;