I'm trying to load a Trading View Widget inside a react component. I tried using _dangerouslySetInnerHTML, however, it doesn't run the javascript code.
I also tried this:
import React from 'react';
export default class TradingView extends React.Component{
constructor(props){
super(props);
}
componentDidMount() {
const tradingViewCode = '<!-- TradingView Widget BEGIN --><script type="text/javascript" src="http://ift.tt/1o6Vmfh"></script><script type="text/javascript">new TradingView.widget({"autosize": true,"symbol": "BITFINEX:BTCUSD","interval": "D","timezone": "America/New_York","theme": "White","style": "1","locale": "en","toolbar_bg": "#f1f3f6","enable_publishing": false,"hide_top_toolbar": true,"save_image": false,"hideideas": true});</script><!-- TradingView Widget END -->';
new Function(tradingViewCode)();
}
render(){
return (
<noscript />
);
}
}
Aucun commentaire:
Enregistrer un commentaire