Conversation
|
WalkthroughHome is now an async page that awaits prefetchQuery; PokemonInfo gains explicit loading and error render paths; Providers narrows children type to a type-only Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant Next as Next.js App Router
participant Home as Home (page.tsx)
participant QC as QueryClient
participant API as Data Source
U->>Next: Request /
Next->>Home: Render (async)
rect rgba(200,240,255,0.25)
note over Home: Await prefetch before returning JSX
Home->>QC: prefetchQuery(key, fetchFn)
QC->>API: fetch data
API-->>QC: data
QC-->>Home: cache populated
end
Home-->>Next: JSX (includes PokemonInfo)
Next-->>U: HTML
sequenceDiagram
autonumber
participant PI as PokemonInfo
participant QC as QueryClient
participant API as Data Source
PI->>QC: useSuspenseQuery(key, fetchFn)
alt Loading
PI-->>PI: Render "Loading..."
else Error
PI-->>PI: Render "Error: {message}"
else Success
QC->>API: (may use cache / fetch)
PI-->>PI: Render data view
end
sequenceDiagram
autonumber
participant Next as Next.js Error Boundary
participant Err as Error (client)
participant Dev as Developer / User
Next->>Err: Render with { error, reset }
Err->>Dev: Display message + "Try again" button
Dev->>Err: Click "Try again"
Err->>Next: call reset()
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🪛 Biome (2.1.2)examples/react/nextjs-app-prefetching/app/error.tsx[error] 3-3: Do not shadow the global "Error" property. Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global. (lint/suspicious/noShadowRestrictedNames) 🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
examples/react/nextjs-app-prefetching/app/page.tsx(1 hunks)examples/react/nextjs-app-prefetching/app/pokemon-info.tsx(1 hunks)examples/react/nextjs-app-prefetching/app/providers.tsx(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
examples/react/nextjs-app-prefetching/app/pokemon-info.tsx (1)
examples/react/nextjs-app-prefetching/app/pokemon.ts (1)
pokemonOptions(3-10)
examples/react/nextjs-app-prefetching/app/providers.tsx (1)
integrations/react-next-15/app/providers.tsx (1)
Providers(26-39)
examples/react/nextjs-app-prefetching/app/page.tsx (2)
examples/react/nextjs-app-prefetching/app/get-query-client.ts (1)
getQueryClient(25-37)examples/react/nextjs-app-prefetching/app/pokemon.ts (1)
pokemonOptions(3-10)
🔇 Additional comments (2)
examples/react/nextjs-app-prefetching/app/providers.tsx (1)
4-8: LGTM: Cleaner type-only import.The change to
ReactNodewith a type-only import is idiomatic and preferred. Note that this differs fromintegrations/react-next-15/app/providers.tsxwhich usesReact.ReactNode, but different examples having different styles is acceptable.examples/react/nextjs-app-prefetching/app/page.tsx (1)
6-6: LGTM: Absolute import path.The change to an absolute alias path (
@/app/pokemon-info) is consistent with other imports in the file and improves maintainability.
TkDodo
left a comment
There was a problem hiding this comment.
this example is for streaming so we don’t await the promise on the server on purpose. also, suspense doesn’t need error/loading handling the component. not sure what this PR is trying to do ...
🎯 Changes
Fixed Next.js App Router prefetching example to properly implement server-side data prefetching with React Query.
Key Changes
Fixed server component prefetching in
app/page.tsx:asyncto support server-side data fetchingvoid queryClient.prefetchQuery()toawait queryClient.prefetchQuery()to ensure data is prefetched before renderingAdded proper loading and error states in
app/pokemon-info.tsx:useSuspenseQuerydoesn't actually need it)Cleaned up imports in
app/providers.tsx:import type * as Reacttoimport type { ReactNode }Why these changes matter
✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
New Features
Bug Fixes
Refactor