Problem: When a URL param changes, React Router renders components using...


Problem: When a URL param changes, React Router renders components using useSearchParams, even if the params the component reads didn't change.

Example:
Assume the URL params are ?p1=1&p2=2.

If a component only needs p1, ideally it wouldn't render if p2 changes.

Solution:
1.…
Note that once React compiler is stable, this optimization should no longer be relevant. 🔥

View original on X