2017 Update
Currently, there is also another way to do it once for both Android and iOS by adding:
"orientation": "portrait"
in app.json
if you're using Expo:
{
"expo": {
"name": "My app",
"slug": "my-app",
"sdkVersion": "21.0.0",
"privacy": "public",
"orientation": "portrait"
}
}
Or at runtime:
ScreenOrientation.allow()
Example:
ScreenOrientation.allow(ScreenOrientation.Orientation.PORTRAIT);
Note that it only works if you're building with Expo but since this is currently (as of 2017) recommended in official guides on React Native Blog then probably a lot of people are using it so it's worth mentioning as an interesting solution in addition to hacking the Android-specific XML configuration files.
More info:
For more info see:
how to disable rotation in React Native?