Skip to content

Commit

Permalink
fix[devtools/useTransition]: set bound dispatch for useTransition queue
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxyq committed Sep 12, 2023
1 parent 2eed132 commit ae957ad
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/react-reconciler/src/ReactFiberHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2717,12 +2717,20 @@ function startTransition<S>(
// optimistic update anyway to make it less likely the behavior accidentally
// diverges; for example, both an optimistic update and this one should
// share the same lane.
dispatchOptimisticSetState(fiber, false, queue, pendingState);
queue.dispatch = dispatchOptimisticSetState.bind(
null,
fiber,
false,
queue,
pendingState,
);
} else {
ReactCurrentBatchConfig.transition = null;
dispatchSetState(fiber, queue, pendingState);
queue.dispatch = dispatchSetState.bind(null, fiber, queue, pendingState);
}

queue.dispatch();

const currentTransition = (ReactCurrentBatchConfig.transition =
({}: BatchConfigTransition));

Expand Down

0 comments on commit ae957ad

Please sign in to comment.