@@ -172,12 +172,12 @@ export function prepareToUseHooks(componentIdentity: Object): void {
172
172
isInHookUserCodeInDev = false ;
173
173
}
174
174
175
- // Reset the internal hooks state before rendering a component
176
- didScheduleRenderPhaseUpdate = false ;
177
- firstWorkInProgressHook = null ;
178
- numberOfReRenders = 0 ;
179
- renderPhaseUpdates = null ;
180
- workInProgressHook = null ;
175
+ // The following should have already been reset
176
+ // didScheduleRenderPhaseUpdate = false;
177
+ // firstWorkInProgressHook = null;
178
+ // numberOfReRenders = 0;
179
+ // renderPhaseUpdates = null;
180
+ // workInProgressHook = null;
181
181
}
182
182
183
183
export function finishHooks (
@@ -202,14 +202,31 @@ export function finishHooks(
202
202
203
203
children = Component ( props , refOrContext ) ;
204
204
}
205
-
205
+ resetHooksState ( ) ;
206
206
if ( __DEV__ ) {
207
207
isInHookUserCodeInDev = false ;
208
208
}
209
209
210
+ // These were reset via the resetHooksState() call
211
+ // currentlyRenderingComponent = null;
212
+ // didScheduleRenderPhaseUpdate = false;
213
+ // firstWorkInProgressHook = null;
214
+ // numberOfReRenders = 0;
215
+ // renderPhaseUpdates = null;
216
+ // workInProgressHook = null;
217
+
210
218
return children ;
211
219
}
212
220
221
+ // Reset the internal hooks state if an error occurs while rendering a component
222
+ export function resetHooksState ( ) : void {
223
+ didScheduleRenderPhaseUpdate = false ;
224
+ firstWorkInProgressHook = null ;
225
+ numberOfReRenders = 0 ;
226
+ renderPhaseUpdates = null ;
227
+ workInProgressHook = null ;
228
+ }
229
+
213
230
function readContext < T > (
214
231
context: ReactContext< T > ,
215
232
observedBits: void | number | boolean,
0 commit comments