Skip to content

Commit

Permalink
chore: Prevent setting RTL mode in test examples (software-mansion#2130)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
tboba authored and ja1ns committed Oct 9, 2024
1 parent fc27e89 commit 789c27e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
10 changes: 8 additions & 2 deletions FabricTestExample/src/Test654.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';

const Stack = createNativeStackNavigator();

I18nManager.forceRTL(true);

export default function App() {
React.useEffect(() => {
I18nManager.forceRTL(true);

return () => {
I18nManager.forceRTL(false);
};
}, []);

return (
<NavigationContainer>
<Stack.Navigator>
Expand Down
10 changes: 8 additions & 2 deletions FabricTestExample/src/Test831.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ type Props = {

const Stack = createNativeStackNavigator();

I18nManager.forceRTL(true);

export default function App(): JSX.Element {
React.useEffect(() => {
I18nManager.forceRTL(true);

return () => {
I18nManager.forceRTL(false);
};
}, []);

return (
<NavigationContainer>
<Stack.Navigator screenOptions={{ headerShown: false }}>
Expand Down
10 changes: 8 additions & 2 deletions TestsExample/src/Test654.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';

const Stack = createNativeStackNavigator();

I18nManager.forceRTL(true);

export default function App() {
React.useEffect(() => {
I18nManager.forceRTL(true);

return () => {
I18nManager.forceRTL(false);
};
}, []);

return (
<NavigationContainer>
<Stack.Navigator>
Expand Down
10 changes: 8 additions & 2 deletions TestsExample/src/Test831.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ type Props = {

const Stack = createNativeStackNavigator();

I18nManager.forceRTL(true);

export default function App(): JSX.Element {
React.useEffect(() => {
I18nManager.forceRTL(true);

return () => {
I18nManager.forceRTL(false);
};
}, []);

return (
<NavigationContainer>
<Stack.Navigator screenOptions={{ headerShown: false }}>
Expand Down

0 comments on commit 789c27e

Please sign in to comment.