@@ -36,7 +36,6 @@ import {
3636} from 'react-reconciler/src/ReactFiberReconciler' ;
3737import { LegacyRoot } from 'react-reconciler/src/ReactRootTags' ;
3838import getComponentNameFromType from 'shared/getComponentNameFromType' ;
39- import invariant from 'shared/invariant' ;
4039import ReactSharedInternals from 'shared/ReactSharedInternals' ;
4140import { has as hasInstance } from 'shared/ReactInstanceMap' ;
4241
@@ -238,10 +237,10 @@ export function hydrate(
238237 ) ;
239238 }
240239
241- invariant (
242- isValidContainerLegacy ( container ) ,
243- 'Target container is not a DOM element.' ,
244- ) ;
240+ if ( ! isValidContainerLegacy ( container ) ) {
241+ throw new Error ( 'Target container is not a DOM element.' ) ;
242+ }
243+
245244 if ( __DEV__ ) {
246245 const isModernRoot =
247246 isContainerMarkedAsRoot ( container ) &&
@@ -278,10 +277,10 @@ export function render(
278277 ) ;
279278 }
280279
281- invariant (
282- isValidContainerLegacy ( container ) ,
283- 'Target container is not a DOM element.' ,
284- ) ;
280+ if ( ! isValidContainerLegacy ( container ) ) {
281+ throw new Error ( 'Target container is not a DOM element.' ) ;
282+ }
283+
285284 if ( __DEV__ ) {
286285 const isModernRoot =
287286 isContainerMarkedAsRoot ( container ) &&
@@ -309,14 +308,14 @@ export function unstable_renderSubtreeIntoContainer(
309308 containerNode : Container ,
310309 callback : ?Function ,
311310) {
312- invariant (
313- isValidContainerLegacy ( containerNode ) ,
314- 'Target container is not a DOM element.' ,
315- ) ;
316- invariant (
317- parentComponent != null && hasInstance ( parentComponent ) ,
318- 'parentComponent must be a valid React Component' ,
319- ) ;
311+ if ( ! isValidContainerLegacy ( containerNode ) ) {
312+ throw new Error ( 'Target container is not a DOM element.' ) ;
313+ }
314+
315+ if ( parentComponent == null || ! hasInstance ( parentComponent ) ) {
316+ throw new Error ( ' parentComponent must be a valid React Component' ) ;
317+ }
318+
320319 return legacyRenderSubtreeIntoContainer (
321320 parentComponent ,
322321 element ,
@@ -327,10 +326,11 @@ export function unstable_renderSubtreeIntoContainer(
327326}
328327
329328export function unmountComponentAtNode ( container : Container ) {
330- invariant (
331- isValidContainerLegacy ( container ) ,
332- 'unmountComponentAtNode(...): Target container is not a DOM element.' ,
333- ) ;
329+ if ( ! isValidContainerLegacy ( container ) ) {
330+ throw new Error (
331+ 'unmountComponentAtNode(...): Target container is not a DOM element.' ,
332+ ) ;
333+ }
334334
335335 if ( __DEV__ ) {
336336 const isModernRoot =
0 commit comments