@@ -11,6 +11,8 @@ import { isServerRenderHash } from './isServerRenderResult';
11
11
import reactHydrateOrRender from './reactHydrateOrRender' ;
12
12
import { supportsRootApi } from './reactApis' ;
13
13
import { debugTurbolinks } from './turbolinksUtils' ;
14
+ import * as StoreRegistry from './StoreRegistry' ;
15
+ import * as ComponentRegistry from './ComponentRegistry' ;
14
16
15
17
const REACT_ON_RAILS_STORE_ATTRIBUTE = 'data-js-react-on-rails-store' ;
16
18
@@ -66,7 +68,7 @@ class ComponentRenderer {
66
68
67
69
// Wait for all store dependencies to be loaded
68
70
this . renderPromise = Promise . all (
69
- storeDependenciesArray . map ( ( storeName ) => globalThis . ReactOnRails . getOrWaitForStore ( storeName ) ) ,
71
+ storeDependenciesArray . map ( ( storeName ) => StoreRegistry . getOrWaitForStore ( storeName ) ) ,
70
72
) . then ( ( ) => {
71
73
if ( this . state === 'unmounted' ) return Promise . resolve ( ) ;
72
74
return this . render ( el , railsContext ) ;
@@ -87,7 +89,7 @@ class ComponentRenderer {
87
89
try {
88
90
const domNode = document . getElementById ( domNodeId ) ;
89
91
if ( domNode ) {
90
- const componentObj = await globalThis . ReactOnRails . getOrWaitForComponent ( name ) ;
92
+ const componentObj = await ComponentRegistry . getOrWaitForComponent ( name ) ;
91
93
if ( this . state === 'unmounted' ) {
92
94
return ;
93
95
}
@@ -195,13 +197,13 @@ class StoreRenderer {
195
197
}
196
198
197
199
private async hydrate ( railsContext : RailsContext , name : string , props : Record < string , unknown > ) {
198
- const storeGenerator = await globalThis . ReactOnRails . getOrWaitForStoreGenerator ( name ) ;
200
+ const storeGenerator = await StoreRegistry . getOrWaitForStoreGenerator ( name ) ;
199
201
if ( this . state === 'unmounted' ) {
200
202
return ;
201
203
}
202
204
203
205
const store = storeGenerator ( props , railsContext ) ;
204
- globalThis . ReactOnRails . setStore ( name , store ) ;
206
+ StoreRegistry . setStore ( name , store ) ;
205
207
this . state = 'hydrated' ;
206
208
}
207
209
0 commit comments