@@ -11,7 +11,7 @@ import type {Fiber} from './ReactFiber';
1111
1212import getComponentName from 'shared/getComponentName' ;
1313import { getStackAddendumByWorkInProgressFiber } from 'shared/ReactFiberComponentTreeHook' ;
14- import { AsyncUpdates } from './ReactTypeOfInternalContext' ;
14+ import { StrictMode } from './ReactTypeOfInternalContext' ;
1515import warning from 'fbjs/lib/warning' ;
1616
1717type LIFECYCLE =
@@ -21,7 +21,7 @@ type LIFECYCLE =
2121type LifecycleToComponentsMap = { [ lifecycle : LIFECYCLE ] : Array < Fiber > } ;
2222type FiberToLifecycleMap = Map < Fiber , LifecycleToComponentsMap > ;
2323
24- const ReactDebugAsyncWarnings = {
24+ const ReactStrictModeWarnings = {
2525 discardPendingWarnings ( ) : void { } ,
2626 flushPendingAsyncWarnings ( ) : void { } ,
2727 recordLifecycleWarnings ( fiber : Fiber , instance : any ) : void { } ,
@@ -39,13 +39,13 @@ if (__DEV__) {
3939 // Tracks components we have already warned about.
4040 const didWarnSet = new Set ( ) ;
4141
42- ReactDebugAsyncWarnings . discardPendingWarnings = ( ) => {
42+ ReactStrictModeWarnings . discardPendingWarnings = ( ) => {
4343 pendingWarningsMap = new Map ( ) ;
4444 } ;
4545
46- ReactDebugAsyncWarnings . flushPendingAsyncWarnings = ( ) => {
46+ ReactStrictModeWarnings . flushPendingAsyncWarnings = ( ) => {
4747 ( ( pendingWarningsMap : any ) : FiberToLifecycleMap ) . forEach (
48- ( lifecycleWarningsMap , asyncRoot ) => {
48+ ( lifecycleWarningsMap , strictRoot ) => {
4949 const lifecyclesWarningMesages = [ ] ;
5050
5151 Object . keys ( lifecycleWarningsMap ) . forEach ( lifecycle => {
@@ -71,17 +71,17 @@ if (__DEV__) {
7171 } ) ;
7272
7373 if ( lifecyclesWarningMesages . length > 0 ) {
74- const asyncRootComponentStack = getStackAddendumByWorkInProgressFiber (
75- asyncRoot ,
74+ const strictRootComponentStack = getStackAddendumByWorkInProgressFiber (
75+ strictRoot ,
7676 ) ;
7777
7878 warning (
7979 false ,
80- 'Unsafe lifecycle methods were found within the following async tree:%s' +
80+ 'Unsafe lifecycle methods were found within a strict-mode tree:%s' +
8181 '\n\n%s' +
8282 '\n\nLearn more about this warning here:' +
83- '\nhttps://fb.me/react-async-component-lifecycle-hooks ' ,
84- asyncRootComponentStack ,
83+ '\nhttps://fb.me/react-strict-mode-warnings ' ,
84+ strictRootComponentStack ,
8585 lifecyclesWarningMesages . join ( '\n\n' ) ,
8686 ) ;
8787 }
@@ -91,25 +91,25 @@ if (__DEV__) {
9191 pendingWarningsMap = new Map ( ) ;
9292 } ;
9393
94- const getAsyncRoot = ( fiber : Fiber ) : Fiber => {
95- let maybeAsyncRoot = null ;
94+ const getStrictRoot = ( fiber : Fiber ) : Fiber => {
95+ let maybeStrictRoot = null ;
9696
9797 while ( fiber !== null ) {
98- if ( fiber . internalContextTag & AsyncUpdates ) {
99- maybeAsyncRoot = fiber ;
98+ if ( fiber . internalContextTag & StrictMode ) {
99+ maybeStrictRoot = fiber ;
100100 }
101101
102102 fiber = fiber . return ;
103103 }
104104
105- return maybeAsyncRoot ;
105+ return maybeStrictRoot ;
106106 } ;
107107
108- ReactDebugAsyncWarnings . recordLifecycleWarnings = (
108+ ReactStrictModeWarnings . recordLifecycleWarnings = (
109109 fiber : Fiber ,
110110 instance : any ,
111111 ) => {
112- const asyncRoot = getAsyncRoot ( fiber ) ;
112+ const strictRoot = getStrictRoot ( fiber ) ;
113113
114114 // Dedup strategy: Warn once per component.
115115 // This is difficult to track any other way since component names
@@ -121,16 +121,16 @@ if (__DEV__) {
121121 }
122122
123123 let warningsForRoot ;
124- if ( ! pendingWarningsMap . has ( asyncRoot ) ) {
124+ if ( ! pendingWarningsMap . has ( strictRoot ) ) {
125125 warningsForRoot = {
126126 UNSAFE_componentWillMount : [ ] ,
127127 UNSAFE_componentWillReceiveProps : [ ] ,
128128 UNSAFE_componentWillUpdate : [ ] ,
129129 } ;
130130
131- pendingWarningsMap . set ( asyncRoot , warningsForRoot ) ;
131+ pendingWarningsMap . set ( strictRoot , warningsForRoot ) ;
132132 } else {
133- warningsForRoot = pendingWarningsMap . get ( asyncRoot ) ;
133+ warningsForRoot = pendingWarningsMap . get ( strictRoot ) ;
134134 }
135135
136136 const unsafeLifecycles = [ ] ;
@@ -163,4 +163,4 @@ if (__DEV__) {
163163 } ;
164164}
165165
166- export default ReactDebugAsyncWarnings ;
166+ export default ReactStrictModeWarnings ;
0 commit comments