@@ -60,7 +60,7 @@ options._render = vnode => {
6060 if ( previousComponent === currentComponent ) {
6161 hooks . _pendingEffects = [ ] ;
6262 currentComponent . _renderCallbacks = [ ] ;
63- hooks . _list . forEach ( hookItem => {
63+ hooks . _list . some ( hookItem => {
6464 if ( hookItem . _nextValue ) {
6565 hookItem . _value = hookItem . _nextValue ;
6666 }
@@ -83,7 +83,7 @@ options.diffed = vnode => {
8383 const c = vnode . _component ;
8484 if ( c && c . __hooks ) {
8585 if ( c . __hooks . _pendingEffects . length ) afterPaint ( afterPaintEffects . push ( c ) ) ;
86- c . __hooks . _list . forEach ( hookItem => {
86+ c . __hooks . _list . some ( hookItem => {
8787 if ( hookItem . _pendingArgs ) {
8888 hookItem . _args = hookItem . _pendingArgs ;
8989 }
@@ -121,7 +121,7 @@ options.unmount = vnode => {
121121 const c = vnode . _component ;
122122 if ( c && c . __hooks ) {
123123 let hasErrored ;
124- c . __hooks . _list . forEach ( s => {
124+ c . __hooks . _list . some ( s => {
125125 try {
126126 invokeCleanup ( s ) ;
127127 } catch ( e ) {
@@ -133,6 +133,24 @@ options.unmount = vnode => {
133133 }
134134} ;
135135
136+ /**
137+ *
138+ * @returns {import('./internal').HookState }
139+ */
140+ function createHookState ( ) {
141+ return {
142+ _value : undefined ,
143+ _args : undefined ,
144+ _cleanup : undefined ,
145+ _pendingValue : undefined ,
146+ _pendingArgs : undefined ,
147+ _component : undefined ,
148+ _reducer : undefined ,
149+ _context : undefined ,
150+ _factory : undefined
151+ } ;
152+ }
153+
136154/**
137155 * Get a hook's state from the currentComponent
138156 * @param {number } index The index of the hook to get
@@ -158,7 +176,7 @@ function getHookState(index, type) {
158176 } ) ;
159177
160178 if ( index >= hooks . _list . length ) {
161- hooks . _list . push ( { } ) ;
179+ hooks . _list . push ( createHookState ( ) ) ;
162180 }
163181
164182 return hooks . _list [ index ] ;
@@ -248,7 +266,7 @@ export function useReducer(reducer, initialState, init) {
248266 let shouldUpdate =
249267 hookState . _component . props !== p ||
250268 hooksList . every ( x => ! x . _nextValue ) ;
251- hooksList . forEach ( hookItem => {
269+ hooksList . some ( hookItem => {
252270 if ( hookItem . _nextValue ) {
253271 const currentValue = hookItem . _value [ 0 ] ;
254272 hookItem . _value = hookItem . _nextValue ;
0 commit comments