Last active
April 28, 2021 13:23
-
-
Save infantiablue/957243733a64cf3c1935afb0f7cd66f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useEffect(() => { | |
fetchData().then((chartData) => { | |
initChart(chartData); | |
setLatestPrice(parseFloat(chartData.price[chartData.price.length - 1]).toFixed(2)); | |
}); | |
const timerID = setInterval(() => { | |
fetchData().then((chartData) => { | |
updateChart(chartData); | |
setLatestPrice(parseFloat(chartData.price[chartData.price.length - 1]).toFixed(2)); | |
}); | |
}, 1000 * 60); | |
return () => { | |
clearInterval(timerID); | |
}; | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment