Hi,
I would like to know the most efficient way to automatically detect when a user native / token balance changes, refetch it and rerender the component in react?
Currently I fetch the balance in the parent component (App), then I save it in state and pass the balance into the child as prop, and I also set a refresher in the App component as a state and pass the setRefresher into the child as well.
After the user performs the withdrawal operation (in the child component), the refresher in the parent component gets updated using the setRefresher method, and therefore the parent component rerenders and refetches the balance.
But is there a better way to do it?
Would subscribing to the updates in the PolygonTransactions table be a good approach for automatic refetching? Is it possible to subscribe only to the updates of a particular address in that table? And are subscriptions performance heavy?
Thank you.