Skip to content

Commit 46bc556

Browse files
committed
Create unified shaped array
1 parent 027142c commit 46bc556

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

hooks/src/index.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,25 @@ options.unmount = vnode => {
133133
}
134134
};
135135

136+
/**
137+
*
138+
* @returns {import('./internal').HookState}
139+
*/
140+
function createHookState(type) {
141+
return {
142+
_value: undefined,
143+
_nextValue: undefined,
144+
_pendingValue: undefined,
145+
_args: undefined,
146+
_pendingArgs: undefined,
147+
_component: undefined,
148+
_cleanup: undefined,
149+
_context: undefined,
150+
_factory: undefined,
151+
_reducer: undefined
152+
};
153+
}
154+
136155
/**
137156
* Get a hook's state from the currentComponent
138157
* @param {number} index The index of the hook to get
@@ -158,7 +177,7 @@ function getHookState(index, type) {
158177
});
159178

160179
if (index >= hooks._list.length) {
161-
hooks._list.push({});
180+
hooks._list.push(createHookState());
162181
}
163182

164183
return hooks._list[index];

0 commit comments

Comments
 (0)