When to use useMemo?

Basically the decision for whether to use useMemo is:

  1. Do I want this to run every single time the state changes? => Leave it plain
  2. Is it bad if this runs multiple times? => Yes useMemo
  3. Is this slow so it should only run when absolutely necessary => Yes useMemo

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *