1
1
/* eslint-disable max-classes-per-file */
2
- /* eslint-disable react/no-deprecated,@typescript-eslint/no-deprecated -- while we need to support React 16 */
3
2
4
3
import * as ReactDOM from 'react-dom' ;
5
4
import type { ReactElement } from 'react' ;
@@ -8,8 +7,8 @@ import type { RailsContext, RegisteredComponent, RenderFunction, Root } from './
8
7
import { getRailsContext , resetRailsContext } from './context.ts' ;
9
8
import createReactOutput from './createReactOutput.ts' ;
10
9
import { isServerRenderHash } from './isServerRenderResult.ts' ;
11
- import reactHydrateOrRender from './reactHydrateOrRender.ts' ;
12
10
import { supportsRootApi } from './reactApis.ts' ;
11
+ import reactHydrateOrRender from './reactHydrateOrRender.ts' ;
13
12
import { debugTurbolinks } from './turbolinksUtils.ts' ;
14
13
import * as StoreRegistry from './StoreRegistry.ts' ;
15
14
import * as ComponentRegistry from './ComponentRegistry.ts' ;
@@ -103,8 +102,7 @@ class ComponentRenderer {
103
102
}
104
103
105
104
// 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 ;
108
106
109
107
const reactElementOrRouterResult = createReactOutput ( {
110
108
componentObj,
@@ -156,7 +154,9 @@ You should return a React.Component always for the client side entry point.`);
156
154
}
157
155
158
156
try {
159
- ReactDOM . unmountComponentAtNode ( domNode ) ;
157
+ const unmountComponentAtNode = 'unmountComponentAtNode' ;
158
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
159
+ ReactDOM [ unmountComponentAtNode ] ( domNode ) ;
160
160
} catch ( e : unknown ) {
161
161
const error = e instanceof Error ? e : new Error ( 'Unknown error' ) ;
162
162
console . info (
0 commit comments