@@ -11,6 +11,8 @@ import { isServerRenderHash } from './isServerRenderResult';
1111import reactHydrateOrRender from './reactHydrateOrRender' ;
1212import { supportsRootApi } from './reactApis' ;
1313import { debugTurbolinks } from './turbolinksUtils' ;
14+ import StoreRegistry from './StoreRegistry' ;
15+ import ComponentRegistry from './ComponentRegistry' ;
1416
1517const REACT_ON_RAILS_STORE_ATTRIBUTE = 'data-js-react-on-rails-store' ;
1618
@@ -66,7 +68,7 @@ class ComponentRenderer {
6668
6769 // Wait for all store dependencies to be loaded
6870 this . renderPromise = Promise . all (
69- storeDependenciesArray . map ( ( storeName ) => globalThis . ReactOnRails . getOrWaitForStore ( storeName ) ) ,
71+ storeDependenciesArray . map ( ( storeName ) => StoreRegistry . getOrWaitForStore ( storeName ) ) ,
7072 ) . then ( ( ) => {
7173 if ( this . state === 'unmounted' ) return Promise . resolve ( ) ;
7274 return this . render ( el , railsContext ) ;
@@ -87,7 +89,7 @@ class ComponentRenderer {
8789 try {
8890 const domNode = document . getElementById ( domNodeId ) ;
8991 if ( domNode ) {
90- const componentObj = await globalThis . ReactOnRails . getOrWaitForComponent ( name ) ;
92+ const componentObj = await ComponentRegistry . getOrWaitForComponent ( name ) ;
9193 if ( this . state === 'unmounted' ) {
9294 return ;
9395 }
@@ -195,13 +197,13 @@ class StoreRenderer {
195197 }
196198
197199 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 ) ;
199201 if ( this . state === 'unmounted' ) {
200202 return ;
201203 }
202204
203205 const store = storeGenerator ( props , railsContext ) ;
204- globalThis . ReactOnRails . setStore ( name , store ) ;
206+ StoreRegistry . setStore ( name , store ) ;
205207 this . state = 'hydrated' ;
206208 }
207209
0 commit comments