React Native :react native undefined 不是一个对象(评估'this._lazyCallableModules [英] React Native : react native undefined is not an object (evaluating 'this._lazyCallableModules

查看:38
本文介绍了React Native :react native undefined 不是一个对象(评估'this._lazyCallableModules的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始尝试 React Native android 应用程序开发,但遇到了这个错误.

I'm new to try react native android app development, and got this error.

这是我的 index.android.js

This is my 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 上发现这个问题: https://github.com/facebook/react-native/issues/14933#issuecomment-314150944,试试改变你的babel-preset-react-nativepackage.json 到 2.0.0 然后运行 ​​npm install 并做 watchman watch-del-all,然后尝试开始运行又是这个项目.

Found this issue on react-native's repo: https://github.com/facebook/react-native/issues/14933#issuecomment-314150944, try change your babel-preset-react-native in package.json to 2.0.0 and then run npm install and do watchman watch-del-all, then try start running the project again.

不确定这是否是问题,但请尝试一下:将 import React from 'react'; 改为 import React, { Component } from 'react';

Not sure if this would be the issue, but try it out: change import React from 'react'; into import React, { Component } from 'react';

然后将export default class App extends React.Component改为export default class App extends Component

这篇关于React Native :react native undefined 不是一个对象(评估'this._lazyCallableModules的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆