Skip to content

Commit 789c27e

Browse files
tbobaja1ns
authored andcommitted
chore: Prevent setting RTL mode in test examples (software-mansion#2130)
## Description This PR is a follow-up to software-mansion#2084 that fixes setting incorrect RTL mode in our example apps. The reason why it is being forced is that `I18nManager.forceRTL(true)` is being called from the global scope, which causes to force RTL, even if we're only importing the component **from file**. ## Changes - Moved `I18nManager.forceRTL(true);` to inner scope of App components. ## Test code and steps to reproduce Just run TestsExample & FabricTestExample ¯\_(ツ)_/¯ ## Checklist - [X] Ensured that CI passes
1 parent fc27e89 commit 789c27e

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

FabricTestExample/src/Test654.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';
55

66
const Stack = createNativeStackNavigator();
77

8-
I18nManager.forceRTL(true);
9-
108
export default function App() {
9+
React.useEffect(() => {
10+
I18nManager.forceRTL(true);
11+
12+
return () => {
13+
I18nManager.forceRTL(false);
14+
};
15+
}, []);
16+
1117
return (
1218
<NavigationContainer>
1319
<Stack.Navigator>

FabricTestExample/src/Test831.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ type Props = {
1212

1313
const Stack = createNativeStackNavigator();
1414

15-
I18nManager.forceRTL(true);
16-
1715
export default function App(): JSX.Element {
16+
React.useEffect(() => {
17+
I18nManager.forceRTL(true);
18+
19+
return () => {
20+
I18nManager.forceRTL(false);
21+
};
22+
}, []);
23+
1824
return (
1925
<NavigationContainer>
2026
<Stack.Navigator screenOptions={{ headerShown: false }}>

TestsExample/src/Test654.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';
55

66
const Stack = createNativeStackNavigator();
77

8-
I18nManager.forceRTL(true);
9-
108
export default function App() {
9+
React.useEffect(() => {
10+
I18nManager.forceRTL(true);
11+
12+
return () => {
13+
I18nManager.forceRTL(false);
14+
};
15+
}, []);
16+
1117
return (
1218
<NavigationContainer>
1319
<Stack.Navigator>

TestsExample/src/Test831.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ type Props = {
1212

1313
const Stack = createNativeStackNavigator();
1414

15-
I18nManager.forceRTL(true);
16-
1715
export default function App(): JSX.Element {
16+
React.useEffect(() => {
17+
I18nManager.forceRTL(true);
18+
19+
return () => {
20+
I18nManager.forceRTL(false);
21+
};
22+
}, []);
23+
1824
return (
1925
<NavigationContainer>
2026
<Stack.Navigator screenOptions={{ headerShown: false }}>

0 commit comments

Comments
 (0)