@@ -15,7 +15,6 @@ import shallowEqual from 'shared/shallowEqual';
15
15
import invariant from 'shared/invariant' ;
16
16
import checkPropTypes from 'prop-types/checkPropTypes' ;
17
17
import ReactSharedInternals from 'shared/ReactSharedInternals' ;
18
- import { enableHooks } from 'shared/ReactFeatureFlags' ;
19
18
import warning from 'shared/warning' ;
20
19
import is from 'shared/objectIs' ;
21
20
@@ -187,17 +186,15 @@ class ReactShallowRenderer {
187
186
this . _rendering = false ;
188
187
this . _forcedUpdate = false ;
189
188
this . _updater = new Updater ( this ) ;
190
- if ( enableHooks ) {
191
- this . _dispatcher = this . _createDispatcher ( ) ;
192
- this . _workInProgressHook = null ;
193
- this . _firstWorkInProgressHook = null ;
194
- this . _isReRender = false ;
195
- this . _didScheduleRenderPhaseUpdate = false ;
196
- this . _renderPhaseUpdates = null ;
197
- this . _currentlyRenderingComponent = null ;
198
- this . _numberOfReRenders = 0 ;
199
- this . _previousComponentIdentity = null ;
200
- }
189
+ this . _dispatcher = this . _createDispatcher ( ) ;
190
+ this . _workInProgressHook = null ;
191
+ this . _firstWorkInProgressHook = null ;
192
+ this . _isReRender = false ;
193
+ this . _didScheduleRenderPhaseUpdate = false ;
194
+ this . _renderPhaseUpdates = null ;
195
+ this . _currentlyRenderingComponent = null ;
196
+ this . _numberOfReRenders = 0 ;
197
+ this . _previousComponentIdentity = null ;
201
198
}
202
199
203
200
_context: null | Object;
@@ -560,27 +557,19 @@ class ReactShallowRenderer {
560
557
561
558
this._mountClassComponent(element, this._context);
562
559
} else {
563
- if ( enableHooks ) {
564
- const prevDispatcher = ReactCurrentDispatcher . current ;
565
- ReactCurrentDispatcher . current = this . _dispatcher ;
566
- this . _prepareToUseHooks ( element . type ) ;
567
- try {
568
- this. _rendered = element . type . call (
569
- undefined ,
570
- element . props ,
571
- this . _context ,
572
- ) ;
573
- } finally {
574
- ReactCurrentDispatcher . current = prevDispatcher ;
575
- }
576
- this._finishHooks(element, context);
577
- } else {
560
+ const prevDispatcher = ReactCurrentDispatcher . current ;
561
+ ReactCurrentDispatcher . current = this . _dispatcher ;
562
+ this . _prepareToUseHooks ( element . type ) ;
563
+ try {
578
564
this. _rendered = element . type . call (
579
565
undefined ,
580
566
element . props ,
581
567
this . _context ,
582
568
) ;
569
+ } finally {
570
+ ReactCurrentDispatcher . current = prevDispatcher ;
583
571
}
572
+ this._finishHooks(element, context);
584
573
}
585
574
}
586
575
0 commit comments