tradingview / charting-library-examples

Examples of Charting Library integrations with other libraries, frameworks and data transports
MIT License
1.32k stars 744 forks source link

Sample react code -> Unhandled Runtime Error Error: There is no such element - # #361

Closed dsldsl closed 8 months ago

dsldsl commented 8 months ago

I have spent about 20+ hours trying to get a sample working in React + Typescrypt. I have tried the base sample React code on the website and many different variations in this React + Typescripe example libary as well as the Nextjs examples. (I am using nextjs but not using any of the next specific functionality in my app other than running the code through next dev command.)

The error that I can't get past is:

image

The error gets thrown here:

      function createWidget() {
        if (document.getElementById('technical-analysis-chart-demo') && 'TradingView' in window) {
          new window.TradingView.widget({
            container_id: "technical-analysis-chart-demo",
            width: "100%",
            height: "100%",
            autosize: true,

Considering the widget constructor is thrown within an if statement checking that the container exists, I'm not sure what to make of the fact that the error is saying there is no such element.

Any help is greatly appreciated. I have tried so many different variations and am very familiar with React and associated workflows. Thank you!

romfrancois commented 8 months ago

Hmm you don't seem to have checked out our example 🤔 Ours is here.

dsldsl commented 8 months ago

Thank you for the reply. The example was not working for me. I have gotten it working now. Will propose some updates in a PR once I get the rest working.