Commit 9f752e3
Replace Next.js data fetching patterns with React on Rails async props in RSC docs (#2791)
## Summary
Fixes #2523
- Replace `await getProduct()` / `await getUser()` / `await getStats()`
etc. with Rails controller props and `getReactOnRailsAsyncProp` across
all RSC migration docs
- Rewrite waterfall avoidance section to show Ruby-side `emit.call`
parallelization (threads) instead of JS-side `Promise.all` / preload
patterns
- Replace React Query prefetch+hydrate pattern with `initialData` from
Rails props
- Replace SWR server fetch with Rails props as `fallbackData`
- Remove all Server Actions (`'use server'`) examples and add explicit
unsupported notes throughout
- Reduce `React.cache()` section — note that `getReactOnRailsAsyncProp`
already returns a cached promise
- Rewrite progressive streaming section to use async props with ERB
examples
- Fix migration checklist to reference Rails props and
`getReactOnRailsAsyncProp`
- Add corresponding ERB view examples alongside component code examples
**Affected files:**
- `rsc-data-fetching.md` — major rewrite (waterfall, React Query, SWR,
use() hook, React.cache(), Server Actions, hybrid pattern, streaming,
checklist)
- `rsc-component-patterns.md` — Patterns 1, 4, 5 + Mistake 4 note
- `rsc-context-and-state.md` — Providers and Redux examples
- `rsc-third-party-libs.md` — Form libraries table + Server Action form
pattern
- `rsc-troubleshooting.md` — serialization table, Server Action fix,
testing, validation, error catalog
## Test plan
- [ ] Review each code example for correctness — ERB syntax, async props
API, TypeScript types
- [ ] Verify all internal links still resolve (anchors may have changed)
- [ ] Confirm no remaining `await getProduct()` / `await getUser()`
patterns outside of the React.cache() and troubleshooting diagnostic
sections
- [ ] Confirm all `'use server'` references are now in
warning/unsupported contexts only
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Low risk documentation-only update, but it changes recommended
migration patterns (async props, mutations, and caching) so inaccuracies
could mislead adopters.
>
> **Overview**
> Updates the RSC migration docs to **replace Next.js-style server
fetching** (`async` components calling `getX()`/`Promise.all`) with
**React on Rails patterns**: Rails-provided sync props plus streamed
async props via `stream_react_component_with_async_props` and
`getReactOnRailsAsyncProp` (with new ERB examples throughout).
>
> Reworks guidance for common integrations: React Query now seeds the
client cache via Rails props (`initialData`), SWR uses Rails props
(`fallbackData`), and the waterfall section is rewritten around
Ruby-side `emit.call` sequencing/parallelization. Removes Server Actions
examples and adds explicit notes that `'use server'` is unsupported in
React on Rails, with updated mutation, CSRF, testing, and validation
examples centered on Rails controller endpoints.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
9279c97. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Documentation**
* Migration guides now favor props-first: Rails supplies synchronous
props and can stream async props into React.
* New/renamed patterns: Async Props with Suspense, async-prop streaming,
and Async Props → client via use().
* Updated data-fetching, React Query/SWR guidance, and progressive
streaming strategies/examples.
* Replaced Server Actions guidance with Rails-controller form/mutation
patterns; added CSRF, testing, and validation notes.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent bd0de1f commit 9f752e3
5 files changed
Lines changed: 486 additions & 449 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
168 | 174 | | |
169 | 175 | | |
170 | 176 | | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
| 177 | + | |
176 | 178 | | |
177 | 179 | | |
178 | 180 | | |
| |||
190 | 192 | | |
191 | 193 | | |
192 | 194 | | |
193 | | - | |
| 195 | + | |
194 | 196 | | |
195 | 197 | | |
196 | 198 | | |
| |||
327 | 329 | | |
328 | 330 | | |
329 | 331 | | |
330 | | - | |
| 332 | + | |
331 | 333 | | |
332 | | - | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
333 | 345 | | |
334 | 346 | | |
335 | 347 | | |
336 | 348 | | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | 349 | | |
341 | 350 | | |
342 | | - | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
343 | 356 | | |
344 | 357 | | |
345 | | - | |
| 358 | + | |
346 | 359 | | |
347 | | - | |
| 360 | + | |
348 | 361 | | |
349 | 362 | | |
350 | | - | |
| 363 | + | |
351 | 364 | | |
352 | 365 | | |
353 | | - | |
| 366 | + | |
354 | 367 | | |
355 | 368 | | |
356 | 369 | | |
357 | 370 | | |
358 | 371 | | |
359 | | - | |
360 | | - | |
361 | | - | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
362 | 375 | | |
363 | 376 | | |
364 | 377 | | |
| |||
368 | 381 | | |
369 | 382 | | |
370 | 383 | | |
371 | | - | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
372 | 387 | | |
373 | | - | |
| 388 | + | |
374 | 389 | | |
375 | | - | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
376 | 397 | | |
377 | 398 | | |
378 | | - | |
| 399 | + | |
379 | 400 | | |
380 | 401 | | |
381 | 402 | | |
382 | | - | |
383 | | - | |
384 | | - | |
| 403 | + | |
| 404 | + | |
385 | 405 | | |
386 | 406 | | |
387 | 407 | | |
388 | | - | |
389 | | - | |
| 408 | + | |
| 409 | + | |
390 | 410 | | |
391 | 411 | | |
392 | 412 | | |
| |||
415 | 435 | | |
416 | 436 | | |
417 | 437 | | |
418 | | - | |
| 438 | + | |
419 | 439 | | |
420 | 440 | | |
421 | 441 | | |
| |||
507 | 527 | | |
508 | 528 | | |
509 | 529 | | |
| 530 | + | |
| 531 | + | |
510 | 532 | | |
511 | 533 | | |
512 | 534 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
94 | 101 | | |
95 | 102 | | |
96 | 103 | | |
97 | 104 | | |
98 | 105 | | |
99 | 106 | | |
100 | 107 | | |
101 | | - | |
102 | | - | |
103 | | - | |
| 108 | + | |
104 | 109 | | |
105 | 110 | | |
106 | 111 | | |
| |||
222 | 227 | | |
223 | 228 | | |
224 | 229 | | |
225 | | - | |
| 230 | + | |
226 | 231 | | |
227 | 232 | | |
228 | 233 | | |
229 | 234 | | |
230 | | - | |
231 | | - | |
232 | | - | |
| 235 | + | |
233 | 236 | | |
234 | 237 | | |
235 | 238 | | |
| |||
0 commit comments