Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useBalance loads forever on a newly created wallet #165

Open
renra opened this issue Sep 11, 2024 · 0 comments
Open

useBalance loads forever on a newly created wallet #165

renra opened this issue Sep 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@renra
Copy link

renra commented Sep 11, 2024

Describe the bug

A clear and concise description of what the bug is.

const { data, isLoading } = useBalance({ chainId: MyChainId, denom: MyDenom })

console.log(isLoading)

In case of a newly created wallet that has no balance, isLoading is always true which makes it look like the balance is loading forever where instead there's actually no balance.
...

To Reproduce

Steps to reproduce the behavior:

  1. Create an app that connects a wallet and displays a balance using useBalance
  2. Create a new wallet that has no coins
  3. Connect the wallet

Expected behavior

isLoading becomes false to indicate the balance has been loaded. data can continue to be undefined to indicate there is no balance.

Temporary workaround

const { isLoading, data } = useBalances({ chainId: MyChainId, denom: MyDenom })

const balance = isLoading 
  ? undefined
  : (data && data.find((coin) => coin.denom === MyDenom)) || { denom: MyDenom, amount: '0' }
  
return {
  data: balance,
  isLoading
}
@renra renra added the bug Something isn't working label Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant