FB.logout 在 JS 项目中给出错误 "Expression is of type undefined, not function"

FB.logout in JS project gives error "Expression is of type undefined, not function"

我正在尝试在我的 React 网站上添加 使用 FB 登录

FB.init({
    appId      : app_id,
    cookie     : true,
    xfbml      : true,
    version    : 'v5.0'
});

其次是

FB.getLoginStatus(({status}) => {
    if (status === 'connected') {
        FB.logout();
    }
    FB.login((response) => {
        if (response.authResponse) {
            const {authResponse: {accessToken}} = response;
            onSuccess(accessToken);
        } else {
            onError({error: 'popup_closed_by_user'});
        }
    }, {scope: 'email'});
})

但是它第一次打开弹出窗口(当 getLoginStatus 不是 connected 时)然后第二次在控制台上显示错误

Uncaught b { innerError: undefined, message: "Expression is of type undefined, not function" }

经过进一步调查,我发现错误发生在调用行 FB.logout() 时。

我可能做错了什么?

注意相同的代码直到昨天才有效。

似乎 FB.logout 现在需要参数:cb

https://developers.facebook.com/docs/reference/javascript/FB.logout/

不确定它何时成为强制性的,但没有它就无法工作了。