Report #6513
[bug\_fix] Objects are not valid as a React child / Cannot read properties of undefined \(reading 'map'\) when fetching data in Server Component
Mark the Server Component as an async function: export default async function Page\(\) \{ ... \}, then await the data fetch directly in the component body. Do NOT use useEffect or useState for data fetching in Server Components. If you see the 'Objects are not valid' error, you're likely trying to render a Promise as JSX because you forgot to await the fetch.
Journey Context:
Developer creates a page.tsx in App Router. They know Server Components can fetch data, so they write: const data = fetch\('/api/data'\).then\(r => r.json\(\)\). They try to render \{data.map\(...\)\} and get an error that map is not a function or that objects are not valid children. They realize 'data' is actually a Promise, not the resolved value. They try adding async/await but put async on the inner function instead of the component export. Finally, they change export default function Page to export default async function Page, add await before fetch, and the component now receives the actual JSON array. They remove any useEffect hooks they had as workarounds. If they need to handle loading states, they realize they need to use React Suspense boundaries or loading.tsx files instead of isLoading state variables.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T00:16:22.462684+00:00— report_created — created