Skip to content

Commit

Permalink
fix: remove the cancel logic from the BestBuyingOption main useEffect (
Browse files Browse the repository at this point in the history
…#2065)

* fix: remove the cancel logic from the BestBuyingOption main useEffect

* chore: remove console.log
  • Loading branch information
juanmahidalgo authored Nov 30, 2023
1 parent bbaff49 commit 3e5aeb3
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ const BestBuyingOption = ({ asset, tableRef }: Props) => {
}

useEffect(() => {
let cancel = false
if (asset && !isNFT(asset)) {
if (asset.available > 0 && asset.isOnSale) {
setBuyOption(BuyOptions.MINT)
Expand All @@ -76,7 +75,6 @@ const BestBuyingOption = ({ asset, tableRef }: Props) => {
.fetchOrders(params, sortBy)
.then(response => {
if (response.data.length > 0) {
if (cancel) return
setBuyOption(BuyOptions.BUY_LISTING)
setListing({ order: response.data[0], total: response.total })
bidAPI
Expand All @@ -88,28 +86,23 @@ const BestBuyingOption = ({ asset, tableRef }: Props) => {
'1'
)
.then(response => {
if (cancel) return
setIsLoading(false)
setMostExpensiveBid(response.data[0])
})
.catch(error => {
if (!cancel) setIsLoading(false)
console.error(error)
setIsLoading(false)
})
} else {
if (cancel) return
setIsLoading(false)
}
})
.catch(error => {
if (!cancel) setIsLoading(false)
console.error(error)
setIsLoading(false)
})
}
}
return () => {
cancel = true
}
}, [asset, listing])

const customClasses = {
Expand Down

0 comments on commit 3e5aeb3

Please sign in to comment.