我刚开始尝试使用 React 原生 Android 应用程序开发,但遇到了这个错误。
这是我的 index.android.js
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>First Try</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
最佳答案
在react-native的repo上发现了这个issue: https://github.com/facebook/react-native/issues/14933#issuecomment-314150944 ,尝试将 package.json
中的 babel-preset-react-native
更改为 2.0.0 然后运行 npm install
并执行 watchman watch-del-all
,然后尝试重新开始运行项目。
不确定这是否是问题所在,但请尝试一下:
将 import React from 'react';
更改为 import React, { Component } from 'react';
然后将export default class App extends React.Component
改成export default class App extends Component
关于android - react native : react native undefined is not an object (evaluating 'this. _lazyCallableModules,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45662468/