Common mistakes
Common mistakes in the Data fetching guide.
- Reading
user()outside a boundary and expecting a loading flag.user()suspends or throws; readlatest,loadinganderrorfor inline states. - Ignoring
info.signal. The result is dropped either way, but the request keeps running. - Creating the resource in an event handler.
useResourcecreates reactive nodes; call it in the component body (or insidecreateRoot), where an owner exists. Trigger refetches withrefetch(). - Awaiting the write only before
apply. GiveuseOptimisticthe promise that includes the refetch. - Fetching the same data in siblings. Share one resource.
- Forgetting the empty source.
useResource(() => id(), ...)withid()equal to0or""still fetches; onlyfalse,nullandundefinedskip. Returnfalseexplicitly for "nothing to fetch".