According to dozens of articles, including React docs, using useCallback and useMemo hooks helps prevent unnecessary re-renders.
On the other hand, these performance-optimizing hooks are not free and come at a cost. And their benefit might not always offset that cost. So that
MOST OF THE TIME YOU SHOULD NOT BOTHER OPTIMIZING UNNECESSARY RERENDERS
said Kent C. Dodds.
So there should be a tool to measure whether a function/variable is costy to compute and that cannot be relative (e.g. putting console.time() and console.timeEnd() before and after).
Is there a number as time that beyond is considered computationally heavy for most of our product users?
Is there a number as time that beyond is considered computationally heavy for most of our product users
As far as I know- there is no standard definition. In most circumstances, its not required (even for calculations that seem complex - computers are crazy fast).
As a general rule of thumb, if you see/notice delays in dom changes - then is the time to start looking for performance bottlenecks