React Native Expo ScreenOrientation.getOrientationAsync() function returns 1

I am trying to use the ScreenOrientation library to find the device’s orientation in expo.

ScreenOrientation.getOrientationAsync().then((data) => console.log(data));

However, instead of an Orientation object, the function console logs the number 1. Any help?

Hey @jaisabnis,

This is actually expected behavior on iOS and Android. The enum type has the values mapped to an integer that you can see here https://github.com/expo/expo/blob/sdk-38/packages/expo-screen-orientation/src/ScreenOrientation.types.ts So in this instance the promise is resolving to 1 which corresponds to the value of PORTRAIT_UP.

We’re brainstorming on ways to add documentation to help clear up the confusion. If you have any ideas, we are all ears!

Cheers,
Adam

1 Like

Hey thanks for replying. Yeah I think the documentation could really use some more detail. I’ve been using expo and react native for a while now, would love to contribute to the project whether it’s helping with the docs or modules. Let me know if there’s any way I can contribute!

Regards,
Jai Sabnis

Glad to hear you’ve been using Expo consistently and that you’re willing to contribute some of your time and thought to the project, Jai. You can find our guide on contributing here: https://github.com/expo/expo#-contributing

1 Like