Skip to content

Commit bbe62ec

Browse files
committed
Hack to recover from reading the wrong Fiber
1 parent 0038c50 commit bbe62ec

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/react-reconciler/src/ReactFiberHooks.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3355,8 +3355,16 @@ export function requestFormReset(formFiber: Fiber) {
33553355
);
33563356
}
33573357

3358-
const stateHook = ensureFormComponentIsStateful(formFiber);
3358+
let stateHook: Hook = ensureFormComponentIsStateful(formFiber);
33593359
const newResetState = {};
3360+
if (stateHook.next === null) {
3361+
// Hack alert. If formFiber is the workInProgress Fiber then
3362+
// we might get a broken intermediate state. Try the alternate
3363+
// instead.
3364+
// TODO: We should really stash the Queue somewhere stateful
3365+
// just like how setState binds the Queue.
3366+
stateHook = (formFiber.alternate: any).memoizedState;
3367+
}
33603368
const resetStateHook: Hook = (stateHook.next: any);
33613369
const resetStateQueue = resetStateHook.queue;
33623370
dispatchSetStateInternal(

0 commit comments

Comments
 (0)