React-native-orientation: Cannot read property '...' of undefined

Created on 9 Nov 2016  路  7Comments  路  Source: yamill/react-native-orientation

  • Added module using npm i...
  • Linked file
  • Checked cradle files and so on from the readme
  • Can console.log Orientation in my componentdidmount() which returns all the functions

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.

waiting-feedback

Most helpful comment

Same issue with Android. In iOS all is fine

All 7 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

testxin picture testxin  路  4Comments

DriesVS picture DriesVS  路  7Comments

sahas- picture sahas-  路  7Comments

AmmiWang picture AmmiWang  路  3Comments

balmasich picture balmasich  路  6Comments