Решение:
import { Component } from 'react';
import PropTypes from 'prop-types';
import Expo from 'expo';
import { expo } from '../app.json';
const ORIENTATION_DEFAULT = Expo.ScreenOrientation.Orientation.ALL;
const ORIENTATIONS = {
'portrait': Expo.ScreenOrientation.Orientation.PORTRAIT,
'landscape': Expo.ScreenOrientation.Orientation.LANDSCAPE,
'default': ORIENTATION_DEFAULT,
};
export default class ScreenOrientation extends Component {
allow(orientation) {
const key = orientation === 'default' ? expo.orientation : orientation;
Expo.ScreenOrientation.allow(ORIENTATIONS[key] || ORIENTATION_DEFAULT);
}
componentDidMount() {
this.allow(this.props.allow);
}
componentWillUnmount() {
this.allow('default');
}
render() {
return this.props.children;
}
}
ScreenOrientation.propTypes = {
children: PropTypes.node,
allow: PropTypes.oneOf(Object.keys(ORIENTATIONS)),
};