rafaelklaessen / react-tradingview-widget

React component for rendering the TradingView Advanced Real-Time Chart Widget.
MIT License
273 stars 94 forks source link

Chart not loading #81

Open hanuor opened 1 year ago

hanuor commented 1 year ago

Hi,

I've using the library for quite some time. Suddenly it has stopped working.

I'm facing this error: Failed to execute 'querySelector' on 'Document': '#tradingview-widget-0.9069513428408063'

Code - <TradingViewWidget symbol={tvsymbol} interval={getInterval(timeframe)} theme={Themes.DARK} studies={studies} autosize hide_top_toolbar />

Anyone else experiencing the same?
lovepareek commented 1 year ago

Yes me too the same issue coming to my react project also DOMException: Failed to execute 'querySelector' on 'Document': '#tradingview-widget-0.5867662783535181' is not a valid selector Please anyone help

i-gera commented 1 year ago

Yes me too the same issue coming to my react project also DOMException: Failed to execute 'querySelector' on 'Document': '#tradingview-widget-0.5867662783535181' is not a valid selector Please anyone help

I created component for widget without this lib (seems like this lib not supporting any more, idk.. sorry, if I'm wrong)

import React, { useEffect, useRef } from 'react';

let tvScriptLoadingPromise;

const TradingViewWidget = (props) => { const onLoadScriptRef = useRef();

useEffect( () => { // console.log('TradingViewWidget'); onLoadScriptRef.current = createWidget;

  if (!tvScriptLoadingPromise) {
    tvScriptLoadingPromise = new Promise((resolve) => {
      const script = document.createElement('script');
      script.id = 'tradingview-widget-loading-script';
      script.src = 'https://s3.tradingview.com/tv.js';
      script.type = 'text/javascript';
      script.onload = resolve;

      document.head.appendChild(script);
    });
  }

  tvScriptLoadingPromise.then(() => onLoadScriptRef.current && onLoadScriptRef.current());

  return () => onLoadScriptRef.current = null;

  function createWidget() {
    if (document.getElementById('tradingview_c7063') && 'TradingView' in window) {
      new window.TradingView.widget({
        ...props,
        enable_publishing: false,
        allow_symbol_change: true,
        container_id: "tradingview_c7063"
      });
    }
  }
}, [props]

);

return (

); }

export default TradingViewWidget

And used this component instead of widget from this lib. it works! found out example here: https://www.tradingview.com/widget/advanced-chart/

image

parent component looks like this: image

i-gera commented 1 year ago

Hi,

I've using the library for quite some time. Suddenly it has stopped working.

I'm facing this error: Failed to execute 'querySelector' on 'Document': '#tradingview-widget-0.9069513428408063'

Code - <TradingViewWidget symbol={tvsymbol} interval={getInterval(timeframe)} theme={Themes.DARK} studies={studies} autosize hide_top_toolbar />

Anyone else experiencing the same?

And used this component instead of widget from this lib. it works! image

parent component looks like this: image

found out example here: https://www.tradingview.com/widget/advanced-chart/

lovepareek commented 1 year ago

Okay thank you so much for help you saved the day :)

huypham1411 commented 7 months ago

Hi, I've using the library for quite some time. Suddenly it has stopped working. I'm facing this error: Failed to execute 'querySelector' on 'Document': '#tradingview-widget-0.9069513428408063' Code - <TradingViewWidget symbol={tvsymbol} interval={getInterval(timeframe)} theme={Themes.DARK} studies={studies} autosize hide_top_toolbar />

Anyone else experiencing the same?

And used this component instead of widget from this lib. it works! image

parent component looks like this: image

found out example here: https://www.tradingview.com/widget/advanced-chart/

Hi, I just want to ask how can you get the symbol search value when the user changes the symbol? Also, can you get the data or handle event using draw tool with this widget? Thanks