Hasty Briefsbeta

Bilingual

Before You memo() — overreacted

13 hours ago
  • Before applying memo() or useMemo(), first try to split components that change from those that don't.
  • Solution 1: Move state down by extracting the part of the UI that depends on the state into its own component.
  • Solution 2: Lift content up by passing unchanged parts (e.g., as children prop) to the state-dependent component to prevent re-rendering.
  • These techniques improve code clarity and data flow, with performance as a bonus.
  • They complement memo() and useMemo()—use the Profiler and memo() only when these simpler methods aren't enough.