I want to disable rotation only at a certain screen – not to the whole app, how can I do that?
Question posted in React native
The official React Native documentation can be found here.
The official React Native documentation can be found here.
2
Answers
I think you are working with react native project. you can control screen orientation on a per-screen basis using the react-native-orientation-locker library.which allows you to lock the orientation of specific screens while leaving the rest of the app unaffected.
Here’s how you can disable rotation for a specific screen:
1.Install the library using npm
You can use the OrientationLocker component to lock the orientation on a specific screen as below (just example).
lock the orientation on a specific screen
Allow Rotation in Other Screens
Android
Ios
If react-native-orientation-locker did not work for you, you can restrict orientation by using Modal, you can use the supportedOrientations prop in React Native’s Modal component.
This ensures that the modal only supports portrait orientation, even if the rest of the app supports rotation.