react-native-orientation-locker
react-native-orientation-locker copied to clipboard
Android: orientationListener fires only after calling lockScreenOrientation
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.
Could duplicate of #160
But using master doens't resolve the issue.