File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -222,6 +222,7 @@ describe('ReactDOMFiber', () => {
222222
223223 // TODO: remove in React 17
224224 it ( 'should support unstable_createPortal alias' , ( ) => {
225+ spyOnDev ( console , 'warn' ) ;
225226 var portalContainer = document . createElement ( 'div' ) ;
226227
227228 ReactDOM . render (
@@ -233,6 +234,16 @@ describe('ReactDOMFiber', () => {
233234 expect ( portalContainer . innerHTML ) . toBe ( '<div>portal</div>' ) ;
234235 expect ( container . innerHTML ) . toBe ( '<div></div>' ) ;
235236
237+ if ( __DEV__ ) {
238+ expect ( console . warn . calls . count ( ) ) . toBe ( 1 ) ;
239+ expect ( console . warn . calls . argsFor ( 0 ) [ 0 ] ) . toContain (
240+ 'The ReactDOM.unstable_createPortal() alias has been deprecated, ' +
241+ 'and will be removed in React 17+. Update your code to use ' +
242+ 'ReactDOM.createPortal() instead. It has the exact same API, ' +
243+ 'but without the "unstable_" prefix.' ,
244+ ) ;
245+ }
246+
236247 ReactDOM . unmountComponentAtNode ( container ) ;
237248 expect ( portalContainer . innerHTML ) . toBe ( '' ) ;
238249 expect ( container . innerHTML ) . toBe ( '' ) ;
Original file line number Diff line number Diff line change @@ -1263,7 +1263,16 @@ const ReactDOM: Object = {
12631263
12641264 // Temporary alias since we already shipped React 16 RC with it.
12651265 // TODO: remove in React 17.
1266- unstable_createPortal : createPortal ,
1266+ unstable_createPortal ( ...args ) {
1267+ lowPriorityWarning (
1268+ false ,
1269+ 'The ReactDOM.unstable_createPortal() alias has been deprecated, ' +
1270+ 'and will be removed in React 17+. Update your code to use ' +
1271+ 'ReactDOM.createPortal() instead. It has the exact same API, ' +
1272+ 'but without the "unstable_" prefix.' ,
1273+ ) ;
1274+ return createPortal ( ...args ) ;
1275+ } ,
12671276
12681277 unstable_batchedUpdates : ReactGenericBatching . batchedUpdates ,
12691278
You can’t perform that action at this time.
0 commit comments