- docs/agent/external: Vercel react-best-practices and composition-patterns (MIT), Addy Osmani accessibility (MIT), Anthropic frontend-design (Apache-2.0), official Payload skill at v3.92.1 (MIT) — text only, each with its licence, SOURCE.md (repo, commit) and an override note in front of the SKILL.md (ipal-kit first, Payload fetching over swr, DESIGN.md tokens, Payload 3 not 4); manifest.json with sha256 per file - scripts/vendor-external-skills.mjs (maintainer, not shipped): fetches by full commit SHA only, rejects non-text or executable files, regenerates the manifest; --check verifies it - ipal-skills --external [names]: copies ext-* after checking every file against the manifest, downloads nothing, never touches ext-* folders without ipal-kit's SOURCE.md, removes only retired ones it installed; an unknown name stops the run before anything is copied - AGENT.md §14, ipal-setup stage 2 (optional step), README: usage, overrides, how to update the pins - test/externalSkills.test.ts: pins are SHAs, no branch fetch, checksums, text only, licences, override note, installer leaves other folders alone Co-Authored-By: Claude Opus 5.5 <[email protected]>
84 lines
1.5 KiB
Markdown
84 lines
1.5 KiB
Markdown
---
|
|
title: Parallel Data Fetching with Component Composition
|
|
impact: CRITICAL
|
|
impactDescription: eliminates server-side waterfalls
|
|
tags: server, rsc, parallel-fetching, composition
|
|
---
|
|
|
|
## Parallel Data Fetching with Component Composition
|
|
|
|
React Server Components execute sequentially within a tree. Restructure with composition to parallelize data fetching.
|
|
|
|
**Incorrect (Sidebar waits for Page's fetch to complete):**
|
|
|
|
```tsx
|
|
export default async function Page() {
|
|
const header = await fetchHeader()
|
|
return (
|
|
<div>
|
|
<div>{header}</div>
|
|
<Sidebar />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
async function Sidebar() {
|
|
const items = await fetchSidebarItems()
|
|
return <nav>{items.map(renderItem)}</nav>
|
|
}
|
|
```
|
|
|
|
**Correct (both fetch simultaneously):**
|
|
|
|
```tsx
|
|
async function Header() {
|
|
const data = await fetchHeader()
|
|
return <div>{data}</div>
|
|
}
|
|
|
|
async function Sidebar() {
|
|
const items = await fetchSidebarItems()
|
|
return <nav>{items.map(renderItem)}</nav>
|
|
}
|
|
|
|
export default function Page() {
|
|
return (
|
|
<div>
|
|
<Header />
|
|
<Sidebar />
|
|
</div>
|
|
)
|
|
}
|
|
```
|
|
|
|
**Alternative with children prop:**
|
|
|
|
```tsx
|
|
async function Header() {
|
|
const data = await fetchHeader()
|
|
return <div>{data}</div>
|
|
}
|
|
|
|
async function Sidebar() {
|
|
const items = await fetchSidebarItems()
|
|
return <nav>{items.map(renderItem)}</nav>
|
|
}
|
|
|
|
function Layout({ children }: { children: ReactNode }) {
|
|
return (
|
|
<div>
|
|
<Header />
|
|
{children}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default function Page() {
|
|
return (
|
|
<Layout>
|
|
<Sidebar />
|
|
</Layout>
|
|
)
|
|
}
|
|
```
|