Streaming & Suspense — Series 3

Preview — 3 of 10 questions

What do these APIs do (with experimental.taint enabled)?

javascript
import { experimental_taintObjectReference, experimental_taintUniqueValue } from 'react';

const user = await db.user.findUnique({ where: { id } });
experimental_taintObjectReference('Do not pass the full user object to the client', user);
experimental_taintUniqueValue('Do not expose the session token', user, user.sessionToken);
AThey encrypt the object before it crosses to the client
BThey log a warning to the console during development only
CThey delete the sensitive fields from the object
DThey register the object reference / specific value as "tainted", so if that exact reference or value is ever passed as a prop from a Server Component to a Client Component, React throws instead of silently serializing it into the RSC payload — a defense-in-depth guard against leaking server data

What does 'only-no-store' enforce for fetch calls in this segment?

javascript
// app/dashboard/layout.tsx
export const fetchCache = 'only-no-store';
AEvery fetch in this segment must use cache: 'no-store' (or omit caching) — a fetch that explicitly asks for force-cache throws a build/runtime error. It is the strict "this subtree is always dynamic, catch any accidental caching" setting
BAll fetches are forced to cache regardless of their options
CIt disables fetch in the segment entirely
DIt only applies to the layout file, not nested pages

getAds() does not depend on the others. How do you avoid it waiting?

javascript
// Anti-pattern: sequential waterfall
async function Page() {
  const user = await getUser();          // 100ms
  const posts = await getPosts(user.id); // needs user, 100ms
  const ads = await getAds();            // independent, 100ms — but waits!
}
AMove getAds() into a useEffect
BWrap the whole component in React.cache()
CKick off independent work before you await it — call const adsPromise = getAds() early (or a preload(id) helper that starts the fetch), let the dependent chain run, then await adsPromise at the point of use. Independent requests then overlap instead of queueing
DAdd export const dynamic = 'force-dynamic'

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.