Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'ReactCurrentOwner' of undefined #1

Open
Songzanganbu opened this issue Aug 2, 2017 · 0 comments
Open

Cannot read property 'ReactCurrentOwner' of undefined #1

Songzanganbu opened this issue Aug 2, 2017 · 0 comments

Comments

@Songzanganbu
Copy link

您好 我按照你的步骤将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);
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant