Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

react-native-orientation in iOS

$
0
0

I have a project in React Native, and I need lock a orientation a specific view in landscape orientation. But, the code don't work and the screen loop tilting. I find one answer for the problem very similar with mine. But, the solution propose don't work. I already search very hard for one solution.

Sorry for bad english. Someone can help-me?

this is a result of my code

This is my code

import Orientation from 'react-native-orientation-locker';

const App: () => React$Node = () => {
  function _onOrientationDidChange(orientation) {
    if (orientation == 'PORTRAIT') {
      Orientation.lockToLandscapeLeft();
    }
    console.log(orientation);
  }

  React.useEffect(a => {
    Orientation.lockToLandscapeLeft();
    Orientation.addOrientationListener(_onOrientationDidChange);
  }, []);
  return (
    <>
      <StatusBar barStyle="dark-content" />
      <SafeAreaView>
        ...
      </SafeAreaView>
    </>
  );
};

Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>