Mikhail Demin
Mikhail Demin

Reputation: 71

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?

Upvotes: 7

Views: 1352

Answers (1)

VincentCordobes
VincentCordobes

Reputation: 117

Use memo only when rendering a component is expensive

Upvotes: 1

Related Questions