@@ -240,23 +240,15 @@ export function useReducer(reducer, initialState, init) {
240
240
function updateHookState ( p , s , c ) {
241
241
if ( ! hookState . _component . __hooks ) return true ;
242
242
243
- /** @type {(x: import('./internal').HookState) => x is import('./internal').ReducerHookState } */
244
- const isStateHook = x => ! ! x . _component ;
245
- const stateHooks =
246
- hookState . _component . __hooks . _list . filter ( isStateHook ) ;
247
-
248
- const allHooksEmpty = stateHooks . every ( x => ! x . _nextValue ) ;
249
- // When we have no updated hooks in the component we invoke the previous SCU or
250
- // traverse the VDOM tree further.
251
- if ( allHooksEmpty ) {
252
- return prevScu ? prevScu . call ( this , p , s , c ) : true ;
253
- }
243
+ const hooksList = hookState . _component . __hooks . _list ;
254
244
255
245
// We check whether we have components with a nextValue set that
256
246
// have values that aren't equal to one another this pushes
257
247
// us to update further down the tree
258
- let shouldUpdate = hookState . _component . props !== p ;
259
- stateHooks . forEach ( hookItem => {
248
+ let shouldUpdate =
249
+ hookState . _component . props !== p ||
250
+ hooksList . every ( x => ! x . _nextValue ) ;
251
+ hooksList . forEach ( hookItem => {
260
252
if ( hookItem . _nextValue ) {
261
253
const currentValue = hookItem . _value [ 0 ] ;
262
254
hookItem . _value = hookItem . _nextValue ;
@@ -275,7 +267,7 @@ export function useReducer(reducer, initialState, init) {
275
267
}
276
268
}
277
269
278
- return hookState . _nextValue || hookState . _value ;
270
+ return hookState . _value ;
279
271
}
280
272
281
273
/**
0 commit comments