Skip to content

react-uncached-promise ​

use(...) given a promise made while rendering: use(fetch(...)), use(load(id)) where load is an async function, use(new Promise(...)), use(Promise.all(...)), use(x.then(...)).

Why: use(promise) suspends the component until the promise settles, then renders it again. That render makes a new promise, which suspends again: the component never shows, and the request is sent over and over. React only says so in the console. Guide: React.

❌ Rejected (and fetch can reject: unhandled-failure)

tsx
import { use } from "react";

export function Status({ url }: { url: string }) {
  const response = use(fetch(url));
  return <p>{response.status}</p>;
}

✅ Accepted: the promise is made once, outside the render, and passed in

✓ Accepted0 diagnostics
tsx
import { use } from "react";

export function Status({ response }: { response: Promise<Response> }) {
  return <p>{use(response).status}</p>;
}

The caller makes it where the request starts (a route loader, an event handler, a parent's useState(() => fetch(url))), or keeps it in a cache keyed by its arguments. Not reported: use(context), use(promise) with a promise from props or state, and calls to functions that aren't async (they may return a cached promise).

What the rule can't see: a plain function that makes a new promise on every call (only async functions are known to), and promises made in the component body and then passed to use by name.

MIT OR Apache-2.0 · Docs by Gemini 4 Neon Extra