Skip to content

Cannot read property 'ReactCurrentOwner' of undefined #1

Open
@Songzanganbu

Description

@Songzanganbu

您好 我按照你的步骤将RN配置集成到新建的Android项目中弹出两个红屏错误:
1 Cannot read property 'ReactCurrentOwner' of undefined
2 this._lazyCallableModules[name] is not a function
这个是什么原因导致的

package.json

{
"name": "AwesomeProject",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"bundle-android": "react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output app/src/main/assets/index.android.bundle --sourcemap-output app/src/main/assets/index.android.map --assets-dest android/app/src/main/res/"
},
"dependencies": {
"react": "^15.6.1",
"react-native": "^0.46.4"
}
}

index.android.js

'use strict';

import React from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';

class HelloWorld extends React.Component {
render() {
return (

Hello, World

);
}
}
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
},
hello: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
});

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

MyReactActivity.java

public class MyReactActivity extends ReactActivity {

public static void start(Context context){
    Intent intent = new Intent(context, MyReactActivity.class);
    context.startActivity(intent);
}

@Nullable
@Override
protected String getMainComponentName() {
    return "AwesomeProject";
}

}

MyApplication.java

public class MyApplication extends Application implements ReactApplication {

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
        return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
                new MainReactPackage()
        );
    }
};

@Override
public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
}

@Override
public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions