diff --git a/src/content/reference/rsc/server-components.md b/src/content/reference/rsc/server-components.md index cf33f7d2405..73215ddd2be 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) { + return null; + } + return (
-

{note}

+

{note.content}

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

{note}

+

{note.content}

); } @@ -269,7 +273,7 @@ async function Page({id}) { const commentsPromise = db.comments.get(note.id); return (
- {note} +

{note.content}

Loading Comments...

}>