Skip to content

Commit

Permalink
Update overrideHookState to account for bailout
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Feb 27, 2019
1 parent 5dc4515 commit dc1517a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/react-reconciler/src/ReactFiberReconciler.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,18 @@ if (__DEV__) {
}
if (currentHook !== null) {
flushPassiveEffects();

const newState = copyWithSet(currentHook.memoizedState, path, value);
currentHook.memoizedState = newState;
currentHook.baseState = newState;

// We aren't actually adding an update to the queue,
// because there is no update we can add for useReducer hooks that won't trigger an error.
// (There's no appropriate action type for DevTools overrides.)
// As a result though, React will see the scheduled update as a noop and bailout.
// Shallow cloning props works as a workaround for now to bypass the bailout check.
fiber.memoizedProps = {...fiber.memoizedProps};

scheduleWork(fiber, Sync);
}
};
Expand Down

0 comments on commit dc1517a

Please sign in to comment.