File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -222,6 +222,7 @@ describe('ReactDOMFiber', () => {
222
222
223
223
// TODO: remove in React 17
224
224
it ( 'should support unstable_createPortal alias' , ( ) => {
225
+ spyOnDev ( console , 'warn' ) ;
225
226
const portalContainer = document . createElement ( 'div' ) ;
226
227
227
228
ReactDOM . render (
@@ -233,6 +234,16 @@ describe('ReactDOMFiber', () => {
233
234
expect ( portalContainer . innerHTML ) . toBe ( '<div>portal</div>' ) ;
234
235
expect ( container . innerHTML ) . toBe ( '<div></div>' ) ;
235
236
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
+
236
247
ReactDOM . unmountComponentAtNode ( container ) ;
237
248
expect ( portalContainer . innerHTML ) . toBe ( '' ) ;
238
249
expect ( container . innerHTML ) . toBe ( '' ) ;
Original file line number Diff line number Diff line change @@ -1268,7 +1268,16 @@ const ReactDOM: Object = {
1268
1268
1269
1269
// Temporary alias since we already shipped React 16 RC with it.
1270
1270
// TODO: remove in React 17.
1271
- unstable_createPortal : createPortal ,
1271
+ unstable_createPortal ( ...args ) {
1272
+ lowPriorityWarning (
1273
+ false ,
1274
+ 'The ReactDOM.unstable_createPortal() alias has been deprecated, ' +
1275
+ 'and will be removed in React 17+. Update your code to use ' +
1276
+ 'ReactDOM.createPortal() instead. It has the exact same API, ' +
1277
+ 'but without the "unstable_" prefix.' ,
1278
+ ) ;
1279
+ return createPortal ( ...args ) ;
1280
+ } ,
1272
1281
1273
1282
unstable_batchedUpdates : ReactGenericBatching . batchedUpdates ,
1274
1283
You can’t perform that action at this time.
0 commit comments