React-转换HTML脚本标记以异步加载SDK

问题描述 投票:1回答:1

当前,我正在尝试通过他们的SDK向网站添加手套

我目前的尝试,无法弄清楚如何在加载组件时将其Dom脚本转换为要调用的函数:

export function snapchatSDK() {
  return new Promise(resolve => {
    const script = document.createElement('script');
    script.src = 'https://sdk.snapkit.com/js/v1/create.js';
    document.head.append(script);
  });

}

class Platforms extends React.Component {

  componentDidMount() {
    snapchatSDK();
  }

render() {
    return (
      <div>
      <p> Share on Social Media Platforms</p>
      <h4>Snapchat<h4>
       <button 
         className="snapchat-creative-kit-share"
         data-share-url= urlTobeShared()
          >
         Share me 
       </button>

       <h4>Twitter<h4>
       <button>
         Share me 
       </button>

      <h4>Reddit<h4>
       <button>
         Share me 
       </button>
      </div>
    );
  }
}

这里也是该文档的链接:snap doc

html reactjs asynchronous dom sdk
1个回答
0
投票

选项1

© www.soinside.com 2019 - 2024. All rights reserved.