-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
28 lines (24 loc) · 847 Bytes
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import './App.css'
import { useD3Chart } from './hooks'; // Import the useStockChart hook
function App() {
const stockSymbol = 'AAPL.US'; // Replace with your desired stock ticker symbol
const year = 2022; // Replace with your desired year
const { chartRef, warning } = useD3Chart(stockSymbol, year); // Call the useD3Chart hook
// If there is a warning (and no data), display it
if (warning !== undefined) {
return (
<div className="App">
<h1>{warning}</h1>
<h3>Stock symbol: <span className='symbol'>{stockSymbol}</span>, year: {year}</h3>
</div>
);
}
// Otherwise, display the chart
return (
<div className="App">
<h1><span className='symbol'>{stockSymbol}</span> Stock Price Chart</h1>
<div ref={chartRef} className='svgChart'></div>
</div>
);
}
export default App