React writes Xiongpang account and wants to share the title and picture set by himself.

when react writes bear paw number, it needs to write the created script to the document asynchronously and dynamically, but there will be a warning, which causes me to share without changing the title of sharing, etc. How can I solve the problem (the annotated part is another method I wrote, but none of it is executed)

this line is my warning
Failed to execute "write" on" Document": It isn"t possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened

Let"s try the code I wrote
componentDidMount () {

    let url = encodeURIComponent(location.href.split("-sharp")[0]);
    console.log(url)
    const params = { url: url }
    getjsssdk(params).then((res) => {
        console.log(res)
        if (res.data.code === 100) {
            // var hm = document.createElement("script");
            // hm.src = "https://xiongzhang.baidu.com/sdk/c.js?" + res.data.data;
            // var s = document.getElementsByTagName("script")[0];
            // s.parentNode.insertBefore(hm, s);

            this.script = document.createElement("script");
            this.script.type = "text/javascript";
            this.script.src = "https://xiongzhang.baidu.com/sdk/c.js?" + res.data.data;
            // document.body.appendChild(this.script);
            document.getElementsByTagName("body")[0].appendChild(this.script);
            window.cambrian.share({
                data: {
                    title: "",
                    content: "",
                },
                // 
                success: function (data) {
                },
                // 
                fail: function (data) {
                }
            });
        }
    }).catch((error) => {

    });
}
Mar.26,2022
Menu