Skip to content

useToken refetches token metadata #627

@bbengamin

Description

@bbengamin

Describe the bug
When switching browser tabs useToken refetches token metadata.
Data fetching is done through SWR library.
tokenAddress briefly becomes null when switching tabs, useToken passes tokenAddress as a dependency, so when tokenAddress changes value SWR executes RPC call once again

To Reproduce
Steps to reproduce the behavior:

  1. Go to swap form on '/'
  2. Click Select token and select any item
  3. Jump to any other tab in your browser
  4. Wait a second and go back
  5. See in network tab that new request is made

Expected behavior
Token metadata is fetched once when token is selected.

Screenshots
Image

Desktop (please complete the following information):

  • OS: Linux
  • Browser google-chrome-stable
  • Version 131.0.6778.264

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions