Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions attachments/25b RSC, Suspense, Server Actions/ClientDemo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default function ClientDemo({ children }) {
console.log('ClientDemo rendered');
return (
<div className='client-cmp'>
<h2>A React Client Component</h2>
<p>
Will be rendered on the client <strong>AND</strong> the server.
</p>
{children}
</div>
);
}
22 changes: 22 additions & 0 deletions attachments/25b RSC, Suspense, Server Actions/DataFetchingDemo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import fs from 'node:fs/promises';

export default async function DataFetchingDemo() {
const data = await fs.readFile('dummy-db.json', 'utf-8');
const users = JSON.parse(data);

return (
<div className='rsc'>
<h2>RSC with Data Fetching</h2>
<p>
Uses <strong>async / await</strong> for data fetching.
</p>
<ul>
{users.map((user) => (
<li key={user.id}>
{user.name} ({user.title})
</li>
))}
</ul>
</div>
);
}
14 changes: 14 additions & 0 deletions attachments/25b RSC, Suspense, Server Actions/RSCDemo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default async function RSCDemo() {
console.log('RSCDemo rendered');
return (
<div className='rsc'>
<h2>A React Server Component</h2>
<p>
Will <strong>ONLY</strong> be rendered on the server or at build time.
</p>
<p>
<strong>NEVER</strong> on the client-side!
</p>
</div>
);
}
4 changes: 4 additions & 0 deletions attachments/25b RSC, Suspense, Server Actions/dummy-db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
{ "id": "u1", "name": "Max Schwarzmüller", "title": "Instructor" },
{ "id": "u2", "name": "Manuel Lorenz", "title": "Instructor" }
]