fetch trade history on history table mount
This commit is contained in:
parent
132802fe12
commit
c59e61df82
|
@ -2,7 +2,6 @@ import useTradeHistory from '../hooks/useTradeHistory'
|
||||||
|
|
||||||
const TradeHistoryTable = () => {
|
const TradeHistoryTable = () => {
|
||||||
const { tradeHistory } = useTradeHistory()
|
const { tradeHistory } = useTradeHistory()
|
||||||
console.log('trade history', tradeHistory)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`flex flex-col py-6`}>
|
<div className={`flex flex-col py-6`}>
|
||||||
|
|
|
@ -84,6 +84,12 @@ export const useTradeHistory = () => {
|
||||||
setAllTrades(formatTradeHistory(results))
|
setAllTrades(formatTradeHistory(results))
|
||||||
}, [marginAccount])
|
}, [marginAccount])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (marginAccount) {
|
||||||
|
fetchTradeHistory()
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
useInterval(() => {
|
useInterval(() => {
|
||||||
if (marginAccount && tradeHistory.length === 0) {
|
if (marginAccount && tradeHistory.length === 0) {
|
||||||
fetchTradeHistory()
|
fetchTradeHistory()
|
||||||
|
|
Loading…
Reference in New Issue