File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-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
var portalContainer = document . createElement ( 'div' ) ;
226
227
227
228
ReactDOM . render (
@@ -233,6 +234,14 @@ 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
+ 'unstable_createPortal is merely an alias to createPortal ' +
241
+ 'and will not work in React 17+. Please update your code.' ,
242
+ ) ;
243
+ }
244
+
236
245
ReactDOM . unmountComponentAtNode ( container ) ;
237
246
expect ( portalContainer . innerHTML ) . toBe ( '' ) ;
238
247
expect ( container . innerHTML ) . toBe ( '' ) ;
Original file line number Diff line number Diff line change @@ -1263,7 +1263,14 @@ const ReactDOM: Object = {
1263
1263
1264
1264
// Temporary alias since we already shipped React 16 RC with it.
1265
1265
// TODO: remove in React 17.
1266
- unstable_createPortal : createPortal ,
1266
+ unstable_createPortal ( ...args ) {
1267
+ lowPriorityWarning (
1268
+ false ,
1269
+ 'unstable_createPortal is merely an alias to createPortal ' +
1270
+ 'and will not work in React 17+. Please update your code.' ,
1271
+ ) ;
1272
+ return createPortal ( ...args ) ;
1273
+ } ,
1267
1274
1268
1275
unstable_batchedUpdates : ReactGenericBatching . batchedUpdates ,
1269
1276
You can’t perform that action at this time.
0 commit comments