Commit 53f08fd
Document content_for pattern to prevent FOUC with SSR and auto_load_bundle
Fixes #1864
When using auto_load_bundle = true with server-side rendering, there's a
chicken-and-egg problem: stylesheets must load in the <head>, but
react_component calls in <body> trigger auto-appends after the head has
rendered, causing FOUC (Flash of Unstyled Content).
This commit documents the content_for workaround pattern and references
the comprehensive Shakapacker FOUC prevention guide (PR #737).
Key improvements:
- Explains the root cause of FOUC with SSR + auto_load_bundle
- Documents the content_for :body_content pattern with execution flow
- Added step-by-step comments showing Rails execution order
- References Shakapacker's comprehensive FOUC prevention documentation
- Links to working example in react-webpack-rails-tutorial PR #686
- Provides alternative solution (disable auto_load_bundle)
- Clarifies that HMR FOUC is separate from this SSR issue
- Addresses code review feedback from PR #1865 comment #3412140475
- Adds FOUC troubleshooting section to docs/deployment/troubleshooting.md
- Includes quick fix example and link to detailed guide
Aligns with Shakapacker PR #737 preventing_fouc.md documentation.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent b3ce154 commit 53f08fd
File tree
2 files changed
+82
-19
lines changed- docs
- core-concepts
- deployment
2 files changed
+82
-19
lines changedLines changed: 47 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
525 | | - | |
| 525 | + | |
526 | 526 | | |
527 | | - | |
| 527 | + | |
528 | 528 | | |
529 | | - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
530 | 569 | | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
| 570 | + | |
536 | 571 | | |
537 | | - | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
538 | 575 | | |
539 | | - | |
540 | | - | |
541 | | - | |
| 576 | + | |
542 | 577 | | |
543 | 578 | | |
544 | 579 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
164 | 165 | | |
165 | 166 | | |
166 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
167 | 195 | | |
168 | 196 | | |
169 | 197 | | |
| |||
0 commit comments