Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable rotation for specific views in react native

Tags:

react-native

How can I disable rotation only for specific views (e.g: when using Navigator) and not for the entire app?

The question here already addresses disabling rotation for the entire app

like image 301
Alon Burg Avatar asked Dec 21 '15 21:12

Alon Burg


1 Answers

With the react-native-orientation package, it's possible to lock the orientation to portrait/landscape. The package and documentation can be found here: https://github.com/yamill/react-native-orientation

Remember; you should not put your locking inside the rendering of scenes (nor the renderScene method). Since the Navigator re-renders all the scenes in the route stack, this would probably cause weird side effects for you. Rather, the locking/unlocking should be put in the code that interacts with the route stack (ie. calls the push/pop methods).

like image 91
Alexander Kuzmin Avatar answered Sep 19 '22 14:09

Alexander Kuzmin