The PR loads a settings payload with useEffect, a raw fetch, and three flags: loading, error, and data. The repo already has React Query (or SWR, or a useApi hook) with a query key, retries, a shared error boundary, and a cache the rest of the app reads. The new effect races on Strict Mode, skips cancellation, and will stale as soon as another screen updates the same resource.
I’ve started treating a hand-rolled fetch effect as incomplete when a data-fetching helper already exists. The cache and the error path are the product, not the await fetch.
Why the effect shows up
The basic React data-fetching example is still useEffect. It is shorter to generate than a query hook with a key. The model will not look at hooks/useSettings.ts unless you paste it.
You also lose the rules the team already agreed on: where query keys live, how 401 is handled, and whether the page should render a cached value while it revalidates.
A simple fetching policy
- New reads go through the existing data-fetching library or helper
- Do not add
useEffect+fetch+ loading state for a resource the cache already knows - Reuse or extend an existing query key, do not invent a string in the component
- Mutations use the existing mutation helper and invalidate the same keys
If the request is truly a one-off fire-and-forget (logging, a beacon), say so. That is not the same as a page-load read.
What to put in the prompt
Use the existing data-fetching helper (useQuery / useSWR / useApi) and the key conventions in src/api. Do not write a useEffect that calls fetch and stores loading/error/data in local state. Reuse or extend an existing query key for this resource. On mutation, invalidate those keys the same way neighboring screens do. Paste one neighboring hook and the key helper. In review, search the diff for useEffect plus fetch(, and for new loading / isLoading state that duplicates the library.
Reject / send back
Reject
- A page that fetches with
useEffectwhen a query helper exists - A second data library added “just for this screen”
- A cache key invented as a raw string, inconsistent with the helpers
- A mutation that does not invalidate the existing key
Accept
- A hook that uses the existing library, keys, and error path
- A small extension to a shared query hook, used by the new screen
- A documented one-off request that is not a page-load read