最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Facebook SDK error: init not called with valid version - Stack Overflow

programmeradmin8浏览0评论

I'm implenting a Facebook share dialog to my React site, and I'm receiving the following error when calling FB.ui():

init not called with valid version

I also manually added <div id="fb-root"></div> to my index file before the FB.init() script is ran. I am using a valid version, and all my FB init and share code is taken directly from the Facebook docs. Has anyone else experienced this bug? Thanks!

I'm implenting a Facebook share dialog to my React site, and I'm receiving the following error when calling FB.ui():

init not called with valid version

I also manually added <div id="fb-root"></div> to my index file before the FB.init() script is ran. I am using a valid version, and all my FB init and share code is taken directly from the Facebook docs. Has anyone else experienced this bug? Thanks!

Share Improve this question edited Nov 9, 2018 at 20:13 awebdev asked Nov 9, 2018 at 20:08 awebdevawebdev 1,1372 gold badges11 silver badges29 bronze badges 6
  • 1 yup, I just edited my question to include that I already added fb-root. @Tholle – awebdev Commented Nov 9, 2018 at 20:14
  • Have you tried adding &version=v2.0 to the js.src in the script? – Tholle Commented Nov 9, 2018 at 20:15
  • 1 Yup, I add ?version=v2.0 to js.src @Tholle – awebdev Commented Nov 9, 2018 at 20:26
  • 1 Ya it's really frustrating :/ Someone asked the same question on here a couple years ago, and there was no official solution. I tried all.js instead of sdk.js. No luck with that either unfortunately. @Tholle – awebdev Commented Nov 9, 2018 at 20:30
  • 1 Just posted a solution that works for me @Tholle – awebdev Commented Nov 9, 2018 at 20:49
 |  Show 1 more ment

1 Answer 1

Reset to default 6

The solution that worked for me was to remove fbAsyncInit() and instead, add the FB.init properties to js.src like so:

js.src = "https://connect.facebook/en_US/sdk.js#version=v2.2&appId=myAppId&xfbml=true&autoLogAppEvents=true";
发布评论

评论列表(0)

  1. 暂无评论