相关疑难解决方法(0)

如何修复错误'FB'在create-react-app项目中没有定义no-undef?

我使用此链接作为我的起始文件制作了项目.

https://github.com/facebookincubator/create-react-app

但在我试图制作Facebook登录按钮后,跟随他们的官方文档.

componentDidMount(){
    console.log('login mount');
    window.fbAsyncInit = function() {
        FB.init({
            appId      : '320866754951228',
            xfbml      : true,
            version    : 'v2.6'
        });

        FB.getLoginStatus(function(response) {
            //this.statusChangeCallback(response);
        });

    };

    (function(d, s, id){
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/en_US/sdk.js";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
}
Run Code Online (Sandbox Code Playgroud)

所以我在刷新浏览器时遇到了这个错误.

Failed to compile.

Error in ./src/components/user_profile/LoginForm.js

/Sites/full_stack_production/xxxxx
  70:13  error  'FB' is not defined  no-undef
  76:13  error  'FB' is not defined  no-undef

? 2 problems (2 errors, 0 …
Run Code Online (Sandbox Code Playgroud)

facebook reactjs eslint create-react-app

14
推荐指数
3
解决办法
7860
查看次数

标签 统计

create-react-app ×1

eslint ×1

facebook ×1

reactjs ×1