react-native: invariant violation: Native component for RCTFBLoginButton does not exist this error is located at: in RCTFBLoginButton

Is this a bug report?

Yes I think this is a real BUG…

Have you read the Contributing Guidelines?

NO

Environment

OS:  macOS Sierra 10.13.3
Node:  ya8.9.4
Yarn:  1.3.2
npm:  5.6.0
Watchman:  4.9.0
Xcode:  9.2    
Packages: (wanted => installed)
react-native: 0.53.0
react:  16.2.0
Target Platform: iOS (10.3)

Steps to Reproduce

(Write your steps here:)

  1. react-native install react-native-fbsdk and then react-native link react-native-fbsdk

  2. Follow ALL STEPS from Quickstart IOS (⚠️ With-out the last STEP, becous the test of integration is with the react-native-fbsdk package)

3 . Then I put this code for testing my wonderful SDKLoginFacebook for React-Native.


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

const FBSDK = require('react-native-fbsdk');
const {
  LoginButton,
  AccessToken
} = FBSDK;

export default class Login extends React.Component {
    render() {
        return (
            <View>
              <LoginButton
                publishPermissions={["publish_actions"]}
                onLoginFinished={
                  (error, result) => {
                    if (error) {
                      alert("login has error: " + result.error);
                    } else if (result.isCancelled) {
                      alert("login is cancelled.");
                    } else {
                      AccessToken.getCurrentAccessToken().then(
                        (data) => {
                          alert(data.accessToken.toString())
                        }
                      )
                    }
                  }
                }
                onLogoutFinished={() => alert("logout.")}/>
            </View>
          );
    }
}
  1. Ejecute react-native run-ios

  2. then, EXPLOTE with this error --> invariant violation: Native component for RCTFBLoginButton does not exist this error is located at: in RCTFBLoginButton at FBLoginButton.js:112

NEED HELP!

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 19
  • Comments: 37

Most upvoted comments

Hello there!
I don’t know why, but, I was try it agains and now works!!! 🎉 The only different that I have done:

  1. reinstalling react-native install react-native-fbsdk && react-native link react-native-fbsdk

  2. follow the quicks steps from ios ⚠️ when tutorial tell you that modify your AppDelegate.m, please copy this ⬇️

AppDelegate.m

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>


@implementation AppDelegate

- (void)applicationDidBecomeActive:(UIApplication *)application {
  [FBSDKAppEvents activateApp];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [[FBSDKApplicationDelegate sharedInstance] application:application
                           didFinishLaunchingWithOptions:launchOptions];
  NSURL *jsCodeLocation;
  
  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
  
  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"PasaLoYa"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
  
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
  return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                        openURL:url
                                              sourceApplication:sourceApplication
                                                     annotation:annotation];
}
@end
  1. Test your LoginButton from react-native-fbsdk 😄 🎉

I think react-native link is really unstable 😔 In my case, many problems solved by linking manually I recommend to refer this explanation

https://github.com/lakshmantgld/react-native-fbsdk-example/blob/master/readmeFiles/fbsdkXcode.md

But, just Ignore react-native link react-native-fbsdk in the explanation above. And add RCTFBSDK.xcodeproj to your project’s Library and libRCTBSDK.a to project’s Link Binary With Libraries

Everything is done perfectly

I have Invariant Violation: requireNativeComponent: "RCTFBLoginButton" was not found in the UIManager., I’ve tried a few ‘solutions’, not much result.

Same crap. What a nightmare.

how do i solve this error?

react

Same problem in android =/

RN: 0.55.4 RNFSDK: ^0.7.0

@CarlosOrozc we don’t know bro, for that we are here jaja

Linking manually was the solution for me. Lately automatic linking has not worked too well on most libraries for some reason. Did exactly what heyman33 said and it worked immediately afterwards. It’s only two steps and it’s worth learning since it saves you a lot of time in many cases.

BTW: Then I had a crash as soon as I pressed the login button, and thanks to some other forum, I simply had to change “publishPermissions” to “readPermissions” in the LoginButton props.

quit the Metro Bundler, and react-native run-ios again

@VGamezz19 I still don’t know what kind of black magic was that but I had the same issue, but following your steps, it’s really working know, after a week of researching and testing.

Thanks man

I’ve faced the same issue today.