But when right bellow I try Orientation.unlockAllOrientations() or .getInitialOrientation() I get Cannot read property '...' of undefined...
What am I missing?
import React, {Component} from 'react';
import {View, Text, StyleSheet, Image, TouchableHighlight} from 'react-native';
let Orientation = require('react-native-orientation');
export class App extends Component {
constructor(props) {
super(props);
}
componentDidMount() {
console.log("App component Mounted", Orientation);
// Orientation.lockToPortrait();
// Orientation.addOrientationListener(this._orientationDidChange);
// Orientation.addOrientationListener(()=>{console.log("It changed")});
Orientation.unlockAllOrientations(); // ==> error
Orientation.addOrientationListener((orientation) => {
console.log('orientation changed', orientation);
}); // ==> does not return anything when device is rotated using emulator
}
...
thank you.
Try using the master branch of the project, add:
"react-native-orientation": "git+https://github.com/yamill/react-native-orientation.git",
to your package.json.
Same issue with Android. In iOS all is fine
I have the same issue.
Same issue on my iPhone 5C / iOS 10.0.2 (don't know if related to iOS version but I don't have this issue on my iPhone and my iPad)
@klinkov Were you able to get to the bottom of it?
@klinkov Could you try and use v2.0.0 that was published to NPM today? You might have to rebuild your application.
It work!
Most helpful comment
Same issue with Android. In iOS all is fine