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 { getContextAndRailsContext , resetContextAndRailsContext , type Context } 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' ;
1413
1514const REACT_ON_RAILS_STORE_ATTRIBUTE = 'data-js-react-on-rails-store' ;
@@ -101,8 +100,7 @@ class ComponentRenderer {
101100 }
102101
103102 // Hydrate if available and was server rendered
104- // @ts -expect-error potentially present if React 18 or greater
105- const shouldHydrate = ! ! ( ReactDOM . hydrate || ReactDOM . hydrateRoot ) && ! ! domNode . innerHTML ;
103+ const shouldHydrate = ( supportsRootApi || 'hydrate' in ReactDOM ) && ! ! domNode . innerHTML ;
106104
107105 const reactElementOrRouterResult = createReactOutput ( {
108106 componentObj,
@@ -154,7 +152,9 @@ You should return a React.Component always for the client side entry point.`);
154152 }
155153
156154 try {
157- ReactDOM . unmountComponentAtNode ( domNode ) ;
155+ const unmountComponentAtNode = 'unmountComponentAtNode' ;
156+ // eslint-disable-next-line @typescript-eslint/no-deprecated
157+ ReactDOM [ unmountComponentAtNode ] ( domNode ) ;
158158 } catch ( e : unknown ) {
159159 const error = e instanceof Error ? e : new Error ( 'Unknown error' ) ;
160160 console . info (
0 commit comments