Problem: React Query keeps a reference to everything that was in scope when...


Problem: React Query keeps a reference to everything that was in scope when the queryFn is created. This may lead to a memory leak.

Solution: Create a custom hook for each useQuery call (typically worth it anyway to support reuse and consistency)

More: https://schiener.io/2024-05-29/react-query-leaks

View original on X