android - react native : react native undefined is not an object (evaluating 'this. _lazyCallableModules

标签 android react-native

我刚开始尝试使用 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',
      },
    });

enter image description here

最佳答案

在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/

相关文章:

java - 如何通过 java 而不是 Firebase 控制台发送 Firebase 推送通知?

android:处理应用程序崩溃并启动特定的 Activity

java - Android Architecture Blueprints "todo‑mvp‑dagger",@Provides for TasksRepository 在哪里?

android - 使用 setContentView 加载布局时显示 ProgressDialog

javascript - react native : filling form without use of state (stateless form)

react-native - React Native 或 NativeBase Picker 可以包含包含图像的项目吗?

react-native - 为什么我在 React Native Expo 应用程序中尝试 Google Login 时会重定向到 "Google.com"?

android - 如何在android中拆分InputStream/OutPutStream

android - 世博会的 SocketTimeOutException

android - 使用 React Native 的移动原生项目