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 expo/ScreenOrientation.types.ts at sdk-38 · expo/expo · GitHub 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!


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!

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: GitHub - expo/expo: An open-source platform for making universal native apps with React. Expo runs on Android, iOS, and the web.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.