I am trying to connect to the Quickbooks Button (https://developer.intuit.com/docs/0100_quickbooks_online/0100_essentials/000500_authentication_and_authorization/widgets#/Connect_to_QuickBooks_button) into a React component, and I am trying to copy the following method: Adding script tag to React/JSX.
The Quickbooks button uses the following script code:
<script
     type="text/javascript"
     src="https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere-1.3.3.js">
</script>
<script src="https://js.appcenter.intuit.com/Content/IA/intuit.ipp.anywhere-1.3.3.js" type="text/javascript"></script>
<script type="text/javascript">
    intuit.ipp.anywhere.setup({
            grantUrl: 'http://www.mycompany.com/HelloWorld/RequestTokenServlet',
            datasources: {
                 quickbooks : true,
                 payments : true
           },
            paymentOptions:{
                  intuitReferred : true
           }
    });
</script>
<body>
    <ipp:connectToIntuit></ipp:connectToIntuit>
</body>
I have tried to use the following React code, which is not working. Any help is appreciated. Thanks.
import React from 'react';
class ConnectToQuickBooksOnlineButton extends React.Component {
    constructor(props){
        super(props);
        this.state = {
        };
    }
    componentWillMount() {
            const library = document.createElement("script");
            library.src = "https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere-1.3.3.js";
            library.type = "text/javascript"
            library.async = true;
            document.body.appendChild(library);
            const setup = document.createElement("script");
            setup.src = "https://js.appcenter.intuit.com/Content/IA/intuit.ipp.anywhere-1.3.3.js";
            setup.type = "text/javascript";
            setup.async = true;
            document.body.appendChild(setup);
            const connect = document.createElement("script");
            connect.type = "text/javascript";
            connect.innerHTML = "intuit.ipp.anywhere.setup({grantUrl: '/quickbooksauth',datasources: {quickbooks : true, payments : true}, paymentOptions:{intuitReferred : true}});"
            document.body.appendChild(connect);
            const body = document.createElement("body");
            body.innerHTML = "<ipp:connectToIntuit></ipp:connectToIntuit>";
            body.async = true;
            document.body.appendChild(body);
    }
    render(){
        return <div />;
    }
};
export default ConnectToQuickBooksOnlineButton;
I tried putting the script stuff in index.html, and calling it from the Quickbooks component. The button is still not displaying though.
import React from 'react';
class ConnectToQuickBooksOnlineButton extends React.Component {
    constructor(props){
        super(props);
        this.state = {
        };
    }
    componentWillMount() {
        const connectToIntuit = document.createElement('ipp:connectToIntuit');
        document.body.appendChild(connectToIntuit);
    }
    render(){
        return <div ref="ipp:connectToIntuit"/>;
    }
};
export default ConnectToQuickBooksOnlineButton;
I have also created the following fiddle: https://jsfiddle.net/aewhatley/7eL716mp/
 
     
     
     
     
    