html.cafe - a realtime HTML editor and host
Edit the html in the top panel, see the result here.
Save your page and get a link to view it live, anywhere.
// TradingViewWidget.jsx
import React, { useEffect, useRef, memo } from 'react';
function TradingViewWidget() {
const container = useRef();
useEffect(
() => {
const script = document.createElement("script");
script.src = "https://s3.tradingview.com/external-embedding/embed-widget-advanced-chart.js";
script.type = "text/javascript";
script.async = true;
script.innerHTML = `
{
"autosize": true,
"symbol": "NASDAQ:AAPL",
"interval": "D",
"timezone": "Etc/UTC",
"theme": "dark",
"style": "1",
"locale": "en",
"allow_symbol_change": true,
"calendar": false,
"support_host": "https://www.tradingview.com"
}`;
container.current.appendChild(script);
},
[]
);
return (
);
}
export default memo(TradingViewWidget);