(fiber, queue, action)
| 15700 | } |
| 15701 | |
| 15702 | function dispatchAction(fiber, queue, action) { |
| 15703 | { |
| 15704 | if (typeof arguments[3] === 'function') { |
| 15705 | error("State updates from the useState() and useReducer() Hooks don't support the " + 'second callback argument. To execute a side effect after ' + 'rendering, declare it in the component body with useEffect().'); |
| 15706 | } |
| 15707 | } |
| 15708 | |
| 15709 | var currentTime = requestCurrentTimeForUpdate(); |
| 15710 | var suspenseConfig = requestCurrentSuspenseConfig(); |
| 15711 | var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); |
| 15712 | var update = { |
| 15713 | expirationTime: expirationTime, |
| 15714 | suspenseConfig: suspenseConfig, |
| 15715 | action: action, |
| 15716 | eagerReducer: null, |
| 15717 | eagerState: null, |
| 15718 | next: null |
| 15719 | }; |
| 15720 | |
| 15721 | { |
| 15722 | update.priority = getCurrentPriorityLevel(); |
| 15723 | } // Append the update to the end of the list. |
| 15724 | |
| 15725 | |
| 15726 | var pending = queue.pending; |
| 15727 | |
| 15728 | if (pending === null) { |
| 15729 | // This is the first update. Create a circular list. |
| 15730 | update.next = update; |
| 15731 | } else { |
| 15732 | update.next = pending.next; |
| 15733 | pending.next = update; |
| 15734 | } |
| 15735 | |
| 15736 | queue.pending = update; |
| 15737 | var alternate = fiber.alternate; |
| 15738 | |
| 15739 | if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) { |
| 15740 | // This is a render phase update. Stash it in a lazily-created map of |
| 15741 | // queue -> linked list of updates. After this render pass, we'll restart |
| 15742 | // and apply the stashed updates on top of the work-in-progress hook. |
| 15743 | didScheduleRenderPhaseUpdate = true; |
| 15744 | update.expirationTime = renderExpirationTime; |
| 15745 | currentlyRenderingFiber$1.expirationTime = renderExpirationTime; |
| 15746 | } else { |
| 15747 | if (fiber.expirationTime === NoWork && (alternate === null || alternate.expirationTime === NoWork)) { |
| 15748 | // The queue is currently empty, which means we can eagerly compute the |
| 15749 | // next state before entering the render phase. If the new state is the |
| 15750 | // same as the current state, we may be able to bail out entirely. |
| 15751 | var lastRenderedReducer = queue.lastRenderedReducer; |
| 15752 | |
| 15753 | if (lastRenderedReducer !== null) { |
| 15754 | var prevDispatcher; |
| 15755 | |
| 15756 | { |
| 15757 | prevDispatcher = ReactCurrentDispatcher.current; |
| 15758 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; |
| 15759 | } |
nothing calls this directly
no test coverage detected