tradingview / charting-library-examples

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

React Router how to use charting-libuary? #136

Open kenneth opened 5 years ago

kenneth commented 5 years ago

React Router will redirect static file charting_library folder and 404 error Any suggestions?

timocov commented 5 years ago

Maybe you can provide some steps to reproduce? Without them I don't think and somebody can help you with that.

kenneth commented 5 years ago

@timocov just like this ,react route can't deal with static file and make charting_library route can't access ,404 error

http://binance.quomap.com/trade/BTCUSDT https://binance.quomap.com/trade/BTCUSDT

import React from 'react'
import { BrowserRouter as Router, Route } from 'react-router-dom'

const App = () => (
  <Router>
    <React.Fragment>
         <Route exact path="/" component={MarketPairs} />
         <Route path="/trade/:symbol" component={Trade} />
    </React.Fragment>
  </Router>
);  

export default App;
timocov commented 5 years ago

When I said "step to reproduce" I mean step-by-step guide to run the issue locally (repo with the example and steps how to run/get the issue).

react route can't deal with static file and make charting_library

Can you serve library's files not by react router but with any other server (like nginx and so on)? All you need to bundle charting_library.min file inside your js bundle (it's API) and then serve library's files somehow (you don't need to serve them with react-router because it's not part of your bundle and you don't need to process them anyhow). But maybe I don't understand you correctly.

linh626688 commented 3 years ago

Hi @timocov I think I have issues with react-router and charting_library too. I started with CRA, I work fine, but when adding react-router and Page have ChartComponent located in a route ( /chart ), the Chart didn't render when I changed route (/chart (show) to /home, to /chart (not show)). I inspected src on browser and not see