wallet
wallet copied to clipboard
Accounts.jsx component read accounts performance.
The way the useEffect for the src/components/Account/Account.jsx
component is implemented is triggering the getAccount
query multiple times ( not necessary on my opinion ) because it is defined to be executed every time the component gets updated ( no dependency set on the array parameter ). While the query is running and returning its corresponding state, the query is called again and again until it gets stopped.
If the purpose of the component is to work as a subscription listening to new events i would:
-
Switch to useQuery and rely on polling parameter to determine a reading interval . ( There is no need for the useEffect since the process will be launched automatically every X time ).
-
May be use a web socket instead of a query and subscribe accordingly so component gets updated when a new event happen WebSocket-Node