Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to to insert TradingView widget into react js which is in script tag link: https://www.tradingview.com/widget/market-overview/

export default class extends Component {
    render() {
        return (
            <div>
                {
                        /***
                         * enter the code here
                          */
                }
            </div>
        )
    }
}
like image 800
Salil Sharma Avatar asked Dec 19 '18 05:12

Salil Sharma


1 Answers

export default  class Tabsshow extends React.PureComponent {
    constructor(props) {
        super(props);
        this._ref = React.createRef();
    }
 componentDidMount() {
        const script = document.createElement('script');
        script.src = 'https://s3.tradingview.com/external-embedding/embed-widget-market-overview.js'
        script.async = true;
        script.innerHTML = /* JSON-ENCODED SETTINGS STRING FROM EMBED CODE */
        this._ref.current.appendChild(script);
    }
    render() {
        return(
        <div class="tradingview-widget-container" ref={this._ref}>
            <div class="tradingview-widget-container__widget"></div>
           
        </div>
        );
    }
   
}
like image 200
Salil Sharma Avatar answered Oct 21 '22 10:10

Salil Sharma