getDynamicGlobalProperties error because of using data outside of hooks
When I refresh Witnesses page I got this error most of the times. Sometime it's error from HC issue, but most of the time this. I inspected the code and I found, that in 4 places:
- Block Table
- VoterDialog
- VotesHistoryDialog
- witnesses page
There is useEffect used to fetch data without standard data hook. And later dynamic global properties are used to get total vesting and total vesting shares. 4 times the same code is copied between components.
I cannot properly debug my HealthChecker because of this. I believe for the project to work properly, you should strictly keep data layers. After FetchingService the next layer is data hook. Create the hook, get the data by it, and later pass it to components. If it is, and I see it is, shared across many component, you may think about adding context or even about creating another hook to calculate or format whatever data you need. But in the way it's done now it's buggy, out of structure, and very bad for overall architecture. Please consider changing it as soon as possible. I can assist with consultation or review.