@@ -15,8 +15,8 @@ import type {ReactNodeList} from 'shared/ReactTypes';
1515import type { FiberRoot } from 'react-reconciler/src/ReactFiberRoot' ;
1616
1717export type RootType = {
18- render ( children : ReactNodeList , callback : ? ( ) => mixed ) : void ,
19- unmount ( callback : ? ( ) = > mixed ) : void ,
18+ render ( children : ReactNodeList ) : void ,
19+ unmount ( ) : void ,
2020 _internalRoot : FiberRoot ,
2121 ...
2222} ;
@@ -62,30 +62,32 @@ function ReactDOMBlockingRoot(
6262
6363ReactDOMRoot . prototype . render = ReactDOMBlockingRoot . prototype . render = function (
6464 children : ReactNodeList ,
65- callback : ?( ) = > mixed ,
6665) : void {
67- const root = this . _internalRoot ;
68- const cb = callback === undefined ? null : callback ;
6966 if ( __DEV__ ) {
70- warnOnInvalidCallback ( cb , 'render' ) ;
67+ if ( arguments . length > 1 && typeof arguments [ 1 ] === 'function' ) {
68+ console . error (
69+ 'render(...): does not support the second callback argument. ' +
70+ 'To execute a side effect after rendering, declare it in a component body with useEffect().' ,
71+ ) ;
72+ }
7173 }
72- updateContainer ( children , root , null , cb ) ;
74+ const root = this . _internalRoot ;
75+ updateContainer ( children , root , null , null ) ;
7376} ;
7477
75- ReactDOMRoot . prototype . unmount = ReactDOMBlockingRoot . prototype . unmount = function (
76- callback : ?( ) = > mixed ,
77- ) : void {
78- const root = this . _internalRoot ;
79- const cb = callback === undefined ? null : callback ;
78+ ReactDOMRoot . prototype . unmount = ReactDOMBlockingRoot . prototype . unmount = function ( ) : void {
8079 if ( __DEV__ ) {
81- warnOnInvalidCallback ( cb , 'render' ) ;
80+ if ( arguments . length > 0 && typeof arguments [ 0 ] === 'function' ) {
81+ console . error (
82+ 'unmount(...): does not support a callback argument. ' +
83+ 'To execute a side effect after rendering, declare it in a component body with useEffect().' ,
84+ ) ;
85+ }
8286 }
87+ const root = this . _internalRoot ;
8388 const container = root . containerInfo ;
8489 updateContainer ( null , root , null , ( ) => {
8590 unmarkContainerAsRoot ( container ) ;
86- if ( cb !== null ) {
87- cb ( ) ;
88- }
8991 } ) ;
9092} ;
9193
@@ -152,22 +154,6 @@ export function isValidContainer(node: mixed): boolean {
152154 ) ;
153155}
154156
155- export function warnOnInvalidCallback (
156- callback : mixed ,
157- callerName : string ,
158- ) : void {
159- if ( __DEV__ ) {
160- if ( callback !== null && typeof callback !== 'function' ) {
161- console . error (
162- '%s(...): Expected the last optional `callback` argument to be a ' +
163- 'function. Instead received: %s.' ,
164- callerName ,
165- callback ,
166- ) ;
167- }
168- }
169- }
170-
171157function warnIfReactDOMContainerInDEV ( container ) {
172158 if ( __DEV__ ) {
173159 if ( isContainerMarkedAsRoot ( container ) ) {
0 commit comments