fetch trade history on history table mount

This commit is contained in:
Tyler Shipe 2021-04-13 17:04:57 -04:00
parent 132802fe12
commit c59e61df82
2 changed files with 6 additions and 1 deletions

View File

@ -2,7 +2,6 @@ import useTradeHistory from '../hooks/useTradeHistory'
const TradeHistoryTable = () => {
const { tradeHistory } = useTradeHistory()
console.log('trade history', tradeHistory)
return (
<div className={`flex flex-col py-6`}>

View File

@ -84,6 +84,12 @@ export const useTradeHistory = () => {
setAllTrades(formatTradeHistory(results))
}, [marginAccount])
useEffect(() => {
if (marginAccount) {
fetchTradeHistory()
}
}, [])
useInterval(() => {
if (marginAccount && tradeHistory.length === 0) {
fetchTradeHistory()