@@ -15,8 +15,8 @@ import type {ReactNodeList} from 'shared/ReactTypes';
15
15
import type { FiberRoot } from 'react-reconciler/src/ReactFiberRoot' ;
16
16
17
17
export type RootType = {
18
- render ( children : ReactNodeList , callback : ? ( ) => mixed ) : void ,
19
- unmount ( callback : ? ( ) = > mixed ) : void ,
18
+ render ( children : ReactNodeList ) : void ,
19
+ unmount ( ) : void ,
20
20
_internalRoot : FiberRoot ,
21
21
...
22
22
} ;
@@ -62,30 +62,32 @@ function ReactDOMBlockingRoot(
62
62
63
63
ReactDOMRoot . prototype . render = ReactDOMBlockingRoot . prototype . render = function (
64
64
children : ReactNodeList ,
65
- callback : ?( ) = > mixed ,
66
65
) : void {
67
- const root = this . _internalRoot ;
68
- const cb = callback === undefined ? null : callback ;
69
66
if ( __DEV__ ) {
70
- warnOnInvalidCallback ( cb , 'render' ) ;
67
+ if ( 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
+ }
71
73
}
72
- updateContainer ( children , root , null , cb ) ;
74
+ const root = this . _internalRoot ;
75
+ updateContainer ( children , root , null , null ) ;
73
76
} ;
74
77
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 {
80
79
if ( __DEV__ ) {
81
- warnOnInvalidCallback ( cb , 'render' ) ;
80
+ if ( 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
+ }
82
86
}
87
+ const root = this . _internalRoot ;
83
88
const container = root . containerInfo ;
84
89
updateContainer ( null , root , null , ( ) => {
85
90
unmarkContainerAsRoot ( container ) ;
86
- if ( cb !== null ) {
87
- cb ( ) ;
88
- }
89
91
} ) ;
90
92
} ;
91
93
@@ -152,22 +154,6 @@ export function isValidContainer(node: mixed): boolean {
152
154
) ;
153
155
}
154
156
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
-
171
157
function warnIfReactDOMContainerInDEV ( container ) {
172
158
if ( __DEV__ ) {
173
159
if ( isContainerMarkedAsRoot ( container ) ) {
0 commit comments