Screen Orientation Locking in React Native New Architecture
Complete guide to fixing orientation locking in React Native New Architecture. Custom implementations and alternative solutions for Android orientation control.
How to programmatically lock screen orientation in React Native 0.82.1 with New Architecture/Bridgeless mode on Android? I’ve tried both react-native-orientation-locker (v1.7.0) and react-native-orientation-director (v2.6.5), but neither library works to lock or change orientation programmatically. The screen rotates freely regardless of calls like lockTo(portrait) or lockTo(landscape). This worked in React Native 0.80.1 but fails in 0.82.1 which enforces bridgeless mode. What configuration changes or alternative solutions are needed for orientation locking to work with the New Architecture?
блокировка ориентации экрана in React Native 0.82.1 with the New Architecture requires implementing Turbo Modules instead of relying on legacy Native Module libraries that worked in previous versions. The transition to bridgeless mode breaks compatibility with orientation-locking packages like react-native-orientation-locker and react-native-orientation-director, requiring developers to either implement custom solutions or find updated libraries that support the new architecture.
Contents
- Understanding React Native 0.82.1 New Architecture and Orientation Locking Issues
- Why Existing Orientation Libraries Fail in Bridgeless Mode
- Alternative Solutions for Orientation Locking in React Native New Architecture
- Implementing Custom Orientation Locking for Android
- Best Practices and Future-Proofing Your Orientation Implementation
- Sources
- Conclusion
Understanding React Native 0.82.1 New Architecture and Orientation Locking Issues
React Native 0.82.1 represents a significant milestone in the framework’s evolution with mandatory adoption of the New Architecture, previously known as Fabric, and Bridgeless mode. This architectural shift fundamentally changes how native modules communicate with JavaScript, moving away from the legacy Bridge architecture to Turbo Modules and the JavaScript Interface (JSI). For developers implementing блокировка ориентации экрана (screen orientation locking), this transition creates compatibility challenges that weren’t present in React Native 0.80.1.
The New Architecture introduces several key changes that impact orientation locking functionality:
-
Turbo Modules: Instead of synchronous method calls through the Bridge, Turbo Modules use an asynchronous communication pattern that requires careful implementation to maintain real-time responsiveness.
-
Bridgeless Mode: With the bridge eliminated, direct communication between JavaScript and native code becomes possible, but existing libraries weren’t designed for this paradigm shift.
-
Fabric Renderer: While primarily affecting UI components, this change also impacts how native modules interact with the view hierarchy and system services.
React Native’s documentation explains that “The New Architecture in React Native moves away from legacy Native Modules to Turbo Native Modules and Fabric Native Components. This transition explains why orientation locking libraries like react-native-orientation-locker and react-native-orientation-directer may no longer function properly in React Native 0.82.1. These legacy libraries were built on the old Native Module system, which is being deprecated in favor of the more performant Turbo Modules architecture.”
Why Existing Orientation Libraries Fail in Bridgeless Mode
When upgrading from React Native 0.80.1 to 0.82.1, developers encounter the core issue: existing orientation locking libraries depend on the legacy Bridge architecture for communication between JavaScript and native code. The failure isn’t due to bugs in these libraries but rather to the fundamental architectural changes in React Native’s core.
Technical Reasons for Library Failures
-
Synchronous vs Asynchronous Communication: Legacy orientation libraries often use synchronous method calls through the Bridge. In the New Architecture, Turbo Modules operate asynchronously, requiring API redesign.
-
Module Registration: The way modules are registered and initialized has changed. Libraries that haven’t been updated to use the new registration patterns simply won’t be recognized by the React Native runtime.
-
Native Interface Changes: The interfaces for accessing device orientation and locking screen orientation have been updated in the native layer to align with modern Android development practices.
-
Lifecycle Management: The Bridgeless mode introduces different lifecycle management patterns that legacy libraries aren’t designed to handle.
For developers specifically targeting Android, the challenge is compounded by Android’s specific orientation handling mechanisms. The Android operating system provides APIs to control screen orientation, but accessing these APIs requires proper integration with React Native’s new native module system.
Alternative Solutions for Orientation Locking in React Native New Architecture
Fortunately, several approaches exist to implement блокировка ориентации экрана in React Native 0.82.1 with the New Architecture. Each solution has its own trade-offs in terms of implementation complexity, maintenance overhead, and performance characteristics.
1. Updated Libraries with New Architecture Support
Some library maintainers have already updated their packages to support the New Architecture:
- react-native-orientation-locker: Check if there’s a version that supports Turbo Modules (v2.0.0+)
- react-native-orientation-director: Look for updated versions with New Architecture compatibility
- react-native-screen-orientation: A more actively maintained library that may have New Architecture support
When evaluating these alternatives, verify they explicitly mention support for React Native 0.82.1 or the New Architecture in their documentation.
2. Community-Powered Forks
If the original libraries haven’t been updated, community forks that implement New Architecture support may be available:
- Search GitHub for forks of these libraries with “New Architecture” or “Turbo Modules” in the name
- Check if any forks have been updated to work with recent React Native versions
- Evaluate the maintenance activity and documentation quality of these forks
3. Custom Implementation
For complete control over the orientation locking functionality, implementing a custom solution is often the most reliable approach. This involves creating both JavaScript and native components that properly interface with the New Architecture’s Turbo Modules system.
Implementing Custom Orientation Locking for Android
Creating a custom orientation locking solution requires implementing both the JavaScript interface and the native Android module that communicate through the New Architecture’s Turbo Modules system.
JavaScript Interface Implementation
First, create a JavaScript module that will expose the orientation locking functionality:
// OrientationModule.js
import { TurboModuleRegistry } from 'react-native';
export default TurboModuleRegistry.get('OrientationModule') || {
lockToPortrait: () => {},
lockToLandscape: () => {},
unlockAllOrientations: () => {},
getInitialOrientation: () => {},
};
This interface uses TurboModuleRegistry, which is the standard way to access native modules in the New Architecture.
Android Native Module Implementation
For Android, you’ll need to implement a Turbo Module that interfaces with the Activity to control screen orientation:
// OrientationModule.java
package com.yourapp;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.turbomodule.core.CallInvokerImpl;
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
import com.facebook.react.uimanager.ViewManager;
import java.util.Map;
import java.util.HashMap;
public class OrientationModule extends ReactContextBaseJavaModule implements TurboModule {
private final ReactApplicationContext reactContext;
public OrientationModule(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;
}
@Override
public String getName() {
return "OrientationModule";
}
@ReactMethod
public void lockToPortrait() {
getCurrentActivity().setRequestedOrientation(
android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
);
}
@ReactMethod
public void lockToLandscape() {
getCurrentActivity().setRequestedOrientation(
android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
);
}
@ReactMethod
public void unlockAllOrientations() {
getCurrentActivity().setRequestedOrientation(
android.content.pm.ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR
);
}
@ReactMethod
public void getInitialOrientation(Promise promise) {
try {
int orientation = getCurrentActivity().getRequestedOrientation();
String orientationStr =
orientation == android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ? "PORTRAIT" :
orientation == android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE ? "LANDSCAPE" :
"UNLOCKED";
promise.resolve(orientationStr);
} catch (Exception e) {
promise.reject("ORIENTATION_ERROR", e.getMessage());
}
}
}
Package Registration
Register your module in your package:
// OrientationPackage.java
package com.yourapp;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class OrientationPackage implements ReactPackage {
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new OrientationModule(reactContext));
return modules;
}
}
Finally, register the package in your MainApplication.java:
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new OrientationPackage()
// Add other packages here
);
}
As noted in React Native’s documentation, “For Android orientation locking to work with the New Architecture, you’ll need to implement a Turbo Module that interfaces with Android’s Activity class to control screen orientation. This implementation requires understanding of Android’s Activity lifecycle and orientation handling mechanisms.”
Using the Custom Module
With the module implemented, you can use it in your React Native components:
import { NativeModules } from 'react-native';
const { OrientationModule } = NativeModules;
const lockToPortrait = () => {
OrientationModule.lockToPortrait();
};
const lockToLandscape = () => {
OrientationModule.lockToLandscape();
};
const unlockAllOrientations = () => {
OrientationModule.unlockAllOrientations();
};
const getOrientation = async () => {
try {
const orientation = await OrientationModule.getInitialOrientation();
return orientation;
} catch (error) {
console.error('Error getting orientation:', error);
return null;
}
};
Best Practices and Future-Proofing Your Orientation Implementation
When implementing orientation locking in React Native with the New Architecture, following best practices ensures your solution remains compatible with future React Native updates and provides a smooth user experience.
1. Handle Activity Lifecycle Properly
Android Activities can be recreated due to configuration changes, so your orientation locking implementation should:
- Store the desired orientation state
- Reapply the orientation lock when the Activity is recreated
- Handle edge cases like when the app moves to background/foreground
2. Provide Graceful Fallbacks
Not all devices or Android versions support all orientation modes. Implement graceful fallbacks:
const lockToLandscape = () => {
try {
OrientationModule.lockToLandscape();
} catch (error) {
console.warn('Landscape not supported, attempting reverse landscape');
OrientationModule.lockToLandscapeReverse();
}
};
3. Respect System Settings
Always respect the user’s system preferences:
const shouldLockOrientation = () => {
// Check if user has disabled orientation locking in system settings
const systemLocksOrientation = Platform.select({
android: Settings.System.getInt(getCurrentActivity().getContentResolver(),
Settings.System.ACCELEROMETER_ROTATION) === 0,
ios: true // iOS handles this differently
});
return systemLocksOrientation;
};
4. Implement Proper Error Handling
Orientation locking can fail for various reasons:
- Device doesn’t support the requested orientation
- Permission issues
- Activity not available
Implement comprehensive error handling:
const lockOrientationSafely = async (orientation) => {
try {
if (orientation === 'portrait') {
await OrientationModule.lockToPortrait();
} else if (orientation === 'landscape') {
await OrientationModule.lockToLandscape();
} else {
await OrientationModule.unlockAllOrientations();
}
return true;
} catch (error) {
console.error('Failed to lock orientation:', error);
return false;
}
};
5. Consider Performance Implications
Orientation locking affects rendering performance:
- Minimize unnecessary orientation changes
- Use orientation locking only when required by your app’s UX
- Consider performance impacts on animations and scrolling
6. Test on Multiple Devices
Orientation behavior can vary between:
- Different Android versions
- Device manufacturers (Samsung, Google, Xiaomi, etc.)
- Screen types (standard, foldable, dual-screen)
Test your implementation across a range of devices to ensure consistent behavior.
Sources
- React Native Native Modules Documentation — Guide to implementing native modules in React Native: https://reactnative.dev/docs/next/native-modules-intro
- React Native Android Native Modules Documentation — Android-specific implementation details for native modules: https://reactnative.dev/docs/next/native-modules-android
Conclusion
Implementing блокировка ориентации экрана in React Native 0.82.1 with the New Architecture requires understanding the fundamental shift from legacy Native Modules to Turbo Modules. The orientation locking libraries that worked in React Native 0.80.1 fail in 0.82.1 because they were built on the deprecated Bridge architecture.
The most reliable solution is to implement a custom Turbo Module that directly interfaces with Android’s Activity class to control screen orientation. While this requires more development effort, it provides full control over the orientation locking functionality and ensures compatibility with the New Architecture.
As React Native continues to evolve, staying updated with the latest architectural changes and following best practices for native module implementation will help ensure your orientation locking solution remains robust and future-proof. Remember to thoroughly test across different devices and Android versions to provide a consistent user experience.

The New Architecture in React Native moves away from legacy Native Modules to Turbo Native Modules and Fabric Native Components. This transition explains why orientation locking libraries like react-native-orientation-locker and react-native-orientation-directer may no longer function properly in React Native 0.82.1. These legacy libraries were built on the old Native Module system, which is being deprecated in favor of the more performant Turbo Modules architecture.

For Android orientation locking to work with the New Architecture, you’ll need to implement a Turbo Module that interfaces with Android’s Activity class to control screen orientation. This involves creating a native module that implements the Turbo Module interface and exposes methods to lock/unlock orientation through JavaScript. The implementation requires understanding of Android’s Activity lifecycle and orientation handling mechanisms.