(React) useMemo

·

1 min read

'useMemo' is used in this situation.

Let's think about a situation.


  1. There is Component A which have part A.

  2. It takes a long time to render part A.

  3. Component A will be rerendered, but part A will not change.


In this situation, if we can save previous part A somewhere and use only the result without calculating (This happens only if there is no change in part A), the rendering time will be shortened a lot.

Below is the example.