[]previous and next page

Common mistakes

Common mistakes in the Data fetching guide.

For agentsUpdated
  • Reading user() outside a boundary and expecting a loading flag. user() suspends or throws; read latest, loading and error for inline states.
  • Ignoring info.signal. The result is dropped either way, but the request keeps running.
  • Creating the resource in an event handler. useResource creates reactive nodes; call it in the component body (or inside createRoot), where an owner exists. Trigger refetches with refetch().
  • Awaiting the write only before apply. Give useOptimistic the promise that includes the refetch.
  • Fetching the same data in siblings. Share one resource.
  • Forgetting the empty source. useResource(() => id(), ...) with id() equal to 0 or "" still fetches; only false, null and undefined skip. Return false explicitly for "nothing to fetch".