Commit 5abe219
committed
Fix component registration race condition by using defer for all scripts
Changes the default loading strategy from :async to :defer to prevent
race conditions where React hydration starts before component registrations
complete.
Root cause: With async script loading, both client-bundle and generated
component packs can execute in any order. When client-bundle executes first,
React attempts to hydrate components that haven't been registered yet,
causing "Could not find component registered with name X" errors.
Solution:
- Default generated_component_packs_loading_strategy to :defer (was :async)
- Use defer: true for client-bundle in dummy app layout
- Update comments to reflect new strategy
With defer, scripts execute in DOM order after parsing, ensuring:
1. Generated component packs load first
2. Components register before main bundle executes
3. React hydration finds all registered components
Fixes CI failures in:
- spec/system/integration_spec.rb[1:1:6:1:2]
- spec/system/integration_spec.rb[1:1:6:2:2]1 parent 9d2710a commit 5abe219
File tree
3 files changed
+13
-19
lines changed- lib/react_on_rails
- spec/dummy
- app/views/layouts
- config/initializers
3 files changed
+13
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
| 157 | + | |
158 | 158 | | |
159 | | - | |
| 159 | + | |
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
185 | 184 | | |
186 | 185 | | |
187 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
22 | 16 | | |
23 | 17 | | |
24 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
| 46 | + | |
46 | 47 | | |
0 commit comments