Common mistakes
Common mistakes in the Suspense and resources guide.
- Reading the resource where no boundary encloses it and expecting a loading UI. The read returns
undefined. Add aSuspensearound the reader, or branch ondata.loading/data.state. - Putting the
SuspensearounduseResourceinstead of arounddata(). The boundary that counts encloses the read. Suspenseinside theErrorBoundaryfallback path. PutErrorBoundaryoutsideSuspense, so failures replace the loading UI too.- Expecting the fallback on refetch. After the first load the old value stays; use
data.loadingfor a spinner. - Using
0or""to mean "do not fetch". Onlyfalse,nullandundefinedskip. - Ignoring
info.signal. The late result is dropped either way, but the request keeps running. - Creating resources in event handlers. A resource needs an owner. Create it in the component body and call
refetch()from the handler. - Unkeyed resources that move between server and client. Give
useResourceakeywhen server data must find its resource.