2015-09-28 112 views
1

根據官方啓動指南here,我正在關注React Native的Hello World示例。當在XCode上運行實際的項目(未修改過,沒有編輯過文件)時,在「紅色死亡屏幕」上出現以下錯誤。React Native - 錯誤:undefined不是一個對象(正在評估'require('NativeModules')。UIManager.AndroidDrawerLayout.Constants')

Error: undefined is not an object (evaluating 'require('NativeModules').UIManager.AndroidDrawerLayout.Constants')

的代碼股票標準的默認代碼什麼也沒有觸及。

任何想法?

謝謝!

Red Screen of Death

/** 
* Sample React Native App 
* https://github.com/facebook/react-native 
*/ 
'use strict'; 

var React = require('react-native'); 
var { 
    AppRegistry, 
    StyleSheet, 
    Text, 
    View, 
} = React; 

var HelloWorld = React.createClass({ 
    render: function() { 
    return (
     <View style={styles.container}> 
     <Text style={styles.welcome}> 
      Welcome to React Native! 
     </Text> 
     <Text style={styles.instructions}> 
      To get started, edit index.ios.js 
     </Text> 
     <Text style={styles.instructions}> 
      Press Cmd+R to reload,{'\n'} 
      Cmd+D or shake for dev menu 
     </Text> 
     </View> 
    ); 
    } 
}); 

var styles = StyleSheet.create({ 
    container: { 
    flex: 1, 
    justifyContent: 'center', 
    alignItems: 'center', 
    backgroundColor: '#F5FCFF', 
    }, 
    welcome: { 
    fontSize: 20, 
    textAlign: 'center', 
    margin: 10, 
    }, 
    instructions: { 
    textAlign: 'center', 
    color: '#333333', 
    marginBottom: 5, 
    }, 
}); 

AppRegistry.registerComponent('HelloWorld',() => HelloWorld); 

回答

2

嘗試在你的應用程序文件夾中運行此命令,然後重新運行該項目:

npm install [email protected] --save 
+0

爲我工作!謝謝!! – csm232s

+0

不幸的是,它仍然發生。 React native現在在package.json上設置爲'「react-native」:「^ 0.11.2」'。我清理了構建並重新編譯了所有內容,並且發生了同樣的錯誤。 –

相關問題