Server Components run on the server and can fetch data directly during rendering. This means less JavaScript is sent to the browser, improving load speed.
import { useState, useEffect } from 'react'; export default function ClientData() { const [data, setData] = useState(null); useEffect(() => { fetch('/api/data').then(res => res.json()).then(setData); }, []); return <div>{data ? data.message : 'Loading...'}</div>; }
useEffect runs only on the client after the component mounts, so data fetching happens after initial render, showing a loading state first.
Option A correctly uses async/await to fetch and parse JSON before returning JSX. Other options misuse promises or omit await.
useEffect expects a synchronous function. Declaring the callback async returns a promise, which React does not handle, causing a syntax error.
{msg || 'Loading...'}
; }The Client Component starts with empty state, so it shows 'Loading...'. After 1 second, useEffect updates the state to show the message.
