Skip to content

Commit f372a40

Browse files
committed
HistographicDataUpdationProblemSolved
1 parent f318111 commit f372a40

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/components/CoinInfo.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const CoinInfo = ({ coin }) => {
1616
const [historicData, setHistoricData] = useState();
1717
const [days, setDays] = useState(1);
1818
const { currency } = CryptoState();
19+
const [flag,setflag] = useState(false);
1920

2021
const useStyles = makeStyles((theme) => ({
2122
container: {
@@ -39,7 +40,7 @@ const CoinInfo = ({ coin }) => {
3940

4041
const fetchHistoricData = async () => {
4142
const { data } = await axios.get(HistoricalChart(coin.id, days, currency));
42-
43+
setflag(true);
4344
setHistoricData(data.prices);
4445
};
4546

@@ -62,7 +63,7 @@ const CoinInfo = ({ coin }) => {
6263
return (
6364
<ThemeProvider theme={darkTheme}>
6465
<div className={classes.container}>
65-
{!historicData ? (
66+
{!historicData | flag===false ? (
6667
<CircularProgress
6768
style={{ color: "gold" }}
6869
size={250}
@@ -108,7 +109,9 @@ const CoinInfo = ({ coin }) => {
108109
{chartDays.map((day) => (
109110
<SelectButton
110111
key={day.value}
111-
onClick={() => setDays(day.value)}
112+
onClick={() => {setDays(day.value);
113+
setflag(false);
114+
}}
112115
selected={day.value === days}
113116
>
114117
{day.label}

0 commit comments

Comments
 (0)