diff --git a/src/content/reference/rsc/server-components.md b/src/content/reference/rsc/server-components.md index cf33f7d2405..2124c57d4ab 100644 --- a/src/content/reference/rsc/server-components.md +++ b/src/content/reference/rsc/server-components.md @@ -100,7 +100,7 @@ Without Server Components, it's common to fetch dynamic data on the client in an ```js // bundle.js function Note({id}) { - const [note, setNote] = useState(''); + const [note, setNote] = useState(null); // NOTE: loads *after* first render. useEffect(() => { fetch(`/api/notes/${id}`).then(data => { @@ -108,10 +108,14 @@ function Note({id}) { }); }, [id]); + if (note == null) { + return null; + } + return (
-

{note}

+

{note.content}

); } @@ -155,7 +159,7 @@ async function Note({id}) { return (
-

{note}

+

{note.content}

); }