DemocracyEarth / wallet

Censorship resistant democracies.
https://democracy.earth
MIT License
1.5k stars 286 forks source link

Accounts.jsx component read accounts performance. #578

Open hbulgarini opened 3 years ago

hbulgarini commented 3 years ago

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:

1) 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 ).

2) May be use a web socket instead of a query and subscribe accordingly so component gets updated when a new event happen WebSocket-Node