Commit 9e17d03
Refactor RSC demo to canonical RoR Pro data flow
Drop self-fetch (Server Component → fetch → Rails) anti-pattern that
docs/oss/migrating/rsc-data-fetching.md and rsc-troubleshooting.md
explicitly warn against (circular request: Node renderer → Rails →
Node renderer). Move comments loading into the Rails controller and
pass them as props through stream_react_component, matching every
maintained RSC demo and the dummy app.
Changes:
- PagesController#server_components now loads @server_components_comments
from the Rails DB and renders via stream_view_containing_react_components.
Includes ReactOnRailsPro::Stream (provides the helper + ActionController::Live).
- View switches react_component → stream_react_component, passes comments
as props.
- ServerComponentsPage receives comments and forwards to CommentsFeed.
- CommentsFeed becomes a pure-render Server Component: receives comments
as a prop, drops fetch / AbortController / RAILS_INTERNAL_URL handling
/ try-catch error fallback / lodash. Keeps marked + sanitize-html for
server-side markdown rendering. Suspense boundary stays; the demo
delay (default-on, RSC_SUSPENSE_DEMO_DELAY=false to disable) gives
Suspense visible work to wait on.
- ServerInfo: drop unused async keyword.
- No PropTypes added (React 19 removed propTypes runtime validation).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent fd9faf1 commit 9e17d03
5 files changed
Lines changed: 20 additions & 59 deletions
File tree
- app
- controllers
- views/pages
- client/app/bundles/server-components
- components
- ror_components
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
42 | 47 | | |
43 | 48 | | |
44 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
Lines changed: 8 additions & 53 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | 1 | | |
5 | 2 | | |
6 | 3 | | |
7 | 4 | | |
8 | | - | |
9 | 5 | | |
10 | 6 | | |
11 | 7 | | |
12 | 8 | | |
13 | 9 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
30 | 14 | | |
31 | 15 | | |
32 | 16 | | |
33 | 17 | | |
34 | 18 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 19 | + | |
63 | 20 | | |
64 | 21 | | |
65 | 22 | | |
| |||
75 | 32 | | |
76 | 33 | | |
77 | 34 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 35 | + | |
| 36 | + | |
82 | 37 | | |
83 | 38 | | |
84 | 39 | | |
| |||
119 | 74 | | |
120 | 75 | | |
121 | 76 | | |
122 | | - | |
| 77 | + | |
123 | 78 | | |
124 | 79 | | |
125 | 80 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| |||
0 commit comments