11/* eslint-disable max-classes-per-file */
2- /* eslint-disable react/no-deprecated,@typescript-eslint/no-deprecated -- while we need to support React 16 */
32
43import * as ReactDOM from 'react-dom' ;
54import type { ReactElement } from 'react' ;
@@ -8,8 +7,8 @@ import type { RailsContext, RegisteredComponent, RenderFunction, Root } from './
87import { getRailsContext , resetRailsContext } from './context.ts' ;
98import createReactOutput from './createReactOutput.ts' ;
109import { isServerRenderHash } from './isServerRenderResult.ts' ;
11- import reactHydrateOrRender from './reactHydrateOrRender.ts' ;
1210import { supportsRootApi } from './reactApis.ts' ;
11+ import reactHydrateOrRender from './reactHydrateOrRender.ts' ;
1312import { debugTurbolinks } from './turbolinksUtils.ts' ;
1413import * as StoreRegistry from './StoreRegistry.ts' ;
1514import * as ComponentRegistry from './ComponentRegistry.ts' ;
@@ -103,8 +102,7 @@ class ComponentRenderer {
103102 }
104103
105104 // Hydrate if available and was server rendered
106- // @ts -expect-error potentially present if React 18 or greater
107- const shouldHydrate = ! ! ( ReactDOM . hydrate || ReactDOM . hydrateRoot ) && ! ! domNode . innerHTML ;
105+ const shouldHydrate = ( supportsRootApi || 'hydrate' in ReactDOM ) && ! ! domNode . innerHTML ;
108106
109107 const reactElementOrRouterResult = createReactOutput ( {
110108 componentObj,
@@ -156,7 +154,9 @@ You should return a React.Component always for the client side entry point.`);
156154 }
157155
158156 try {
159- ReactDOM . unmountComponentAtNode ( domNode ) ;
157+ const unmountComponentAtNode = 'unmountComponentAtNode' ;
158+ // eslint-disable-next-line @typescript-eslint/no-deprecated
159+ ReactDOM [ unmountComponentAtNode ] ( domNode ) ;
160160 } catch ( e : unknown ) {
161161 const error = e instanceof Error ? e : new Error ( 'Unknown error' ) ;
162162 console . info (
0 commit comments