react-native-orientation-locker icon indicating copy to clipboard operation
react-native-orientation-locker copied to clipboard

Android: orientationListener fires only after calling lockScreenOrientation

Open jankaifer opened this issue 5 years ago • 1 comments

Basically orientationChangeListener gets fired only when changing screens (because each screen sets its preferred orientation).

I was able to do this workaround:

  const {width, height} = useWindowDimensions();
  useEffect(() => {
    nativeStore.lockScreenOrientation(orientation); // nativeStore.lockScreenOrientation just makes sure the correct method gets called
  }, [orientation, width, height]);

(I changed dependencies from [orientation] to [orientation, width, height])

Which works, but it still misses few changes sometimes, so I had to fallback to checking whether width < height.

jankaifer avatar Jan 12 '21 11:01 jankaifer

Could duplicate of #160 But using master doens't resolve the issue.

jankaifer avatar Jan 12 '21 11:01 jankaifer