(fiber, queue, action)
| 19260 | } |
| 19261 | |
| 19262 | function dispatchAction(fiber, queue, action) { |
| 19263 | { |
| 19264 | if (typeof arguments[3] === 'function') { |
| 19265 | 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().'); |
| 19266 | } |
| 19267 | } |
| 19268 | |
| 19269 | var currentTime = requestCurrentTimeForUpdate(); |
| 19270 | var suspenseConfig = requestCurrentSuspenseConfig(); |
| 19271 | var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); |
| 19272 | var update = { |
| 19273 | expirationTime: expirationTime, |
| 19274 | suspenseConfig: suspenseConfig, |
| 19275 | action: action, |
| 19276 | eagerReducer: null, |
| 19277 | eagerState: null, |
| 19278 | next: null |
| 19279 | }; |
| 19280 | |
| 19281 | { |
| 19282 | update.priority = getCurrentPriorityLevel(); |
| 19283 | } // Append the update to the end of the list. |
| 19284 | |
| 19285 | |
| 19286 | var pending = queue.pending; |
| 19287 | |
| 19288 | if (pending === null) { |
| 19289 | // This is the first update. Create a circular list. |
| 19290 | update.next = update; |
| 19291 | } else { |
| 19292 | update.next = pending.next; |
| 19293 | pending.next = update; |
| 19294 | } |
| 19295 | |
| 19296 | queue.pending = update; |
| 19297 | var alternate = fiber.alternate; |
| 19298 | |
| 19299 | if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) { |
| 19300 | // This is a render phase update. Stash it in a lazily-created map of |
| 19301 | // queue -> linked list of updates. After this render pass, we'll restart |
| 19302 | // and apply the stashed updates on top of the work-in-progress hook. |
| 19303 | didScheduleRenderPhaseUpdate = true; |
| 19304 | update.expirationTime = renderExpirationTime; |
| 19305 | currentlyRenderingFiber$1.expirationTime = renderExpirationTime; |
| 19306 | } else { |
| 19307 | if (fiber.expirationTime === NoWork && (alternate === null || alternate.expirationTime === NoWork)) { |
| 19308 | // The queue is currently empty, which means we can eagerly compute the |
| 19309 | // next state before entering the render phase. If the new state is the |
| 19310 | // same as the current state, we may be able to bail out entirely. |
| 19311 | var lastRenderedReducer = queue.lastRenderedReducer; |
| 19312 | |
| 19313 | if (lastRenderedReducer !== null) { |
| 19314 | var prevDispatcher; |
| 19315 | |
| 19316 | { |
| 19317 | prevDispatcher = ReactCurrentDispatcher.current; |
| 19318 | ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; |
| 19319 | } |
nothing calls this directly
no test coverage detected