Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid useMemo overusing?

In the docs the following is stated:

useMemo will only recompute the memoized value when one of the dependencies has changed. This optimization helps to avoid expensive calculations on every render.

Sounds nice, isn't it? But to optimize performance one needs to be sure the calculations are more expensive than useMemo itself before using it. Are there any suggestions to when to avoid useMemo?

like image 974
Mikhail Demin Avatar asked Mar 14 '19 11:03

Mikhail Demin


1 Answers

Use memo only when rendering a component is expensive

like image 91
VincentCordobes Avatar answered Oct 20 '22 07:10

VincentCordobes