根据官方启动指南here,我正在关注React Native的Hello World示例。在XCode上运行实际项目(未更改,未编辑文件)时,我在“死亡红屏”上收到以下错误。
Error: undefined is not an object (evaluating 'require('NativeModules').UIManager.AndroidDrawerLayout.Constants')
代码是股票标准默认代码,没有触及。
有什么想法吗?
谢谢!
/**
* 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);
答案 0 :(得分:3)
答案 1 :(得分:2)
尝试在app文件夹中运行此命令,然后重新运行项目:
npm install react-native@0.11.2 --save