(fiber, update)
| 11844 | } |
| 11845 | |
| 11846 | function enqueueUpdate(fiber, update) { |
| 11847 | // Update queues are created lazily. |
| 11848 | var alternate = fiber.alternate; |
| 11849 | var queue1 = void 0; |
| 11850 | var queue2 = void 0; |
| 11851 | if (alternate === null) { |
| 11852 | // There's only one fiber. |
| 11853 | queue1 = fiber.updateQueue; |
| 11854 | queue2 = null; |
| 11855 | if (queue1 === null) { |
| 11856 | queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); |
| 11857 | } |
| 11858 | } else { |
| 11859 | // There are two owners. |
| 11860 | queue1 = fiber.updateQueue; |
| 11861 | queue2 = alternate.updateQueue; |
| 11862 | if (queue1 === null) { |
| 11863 | if (queue2 === null) { |
| 11864 | // Neither fiber has an update queue. Create new ones. |
| 11865 | queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); |
| 11866 | queue2 = alternate.updateQueue = createUpdateQueue(alternate.memoizedState); |
| 11867 | } else { |
| 11868 | // Only one fiber has an update queue. Clone to create a new one. |
| 11869 | queue1 = fiber.updateQueue = cloneUpdateQueue(queue2); |
| 11870 | } |
| 11871 | } else { |
| 11872 | if (queue2 === null) { |
| 11873 | // Only one fiber has an update queue. Clone to create a new one. |
| 11874 | queue2 = alternate.updateQueue = cloneUpdateQueue(queue1); |
| 11875 | } else { |
| 11876 | // Both owners have an update queue. |
| 11877 | } |
| 11878 | } |
| 11879 | } |
| 11880 | if (queue2 === null || queue1 === queue2) { |
| 11881 | // There's only a single queue. |
| 11882 | appendUpdateToQueue(queue1, update); |
| 11883 | } else { |
| 11884 | // There are two queues. We need to append the update to both queues, |
| 11885 | // while accounting for the persistent structure of the list — we don't |
| 11886 | // want the same update to be added multiple times. |
| 11887 | if (queue1.lastUpdate === null || queue2.lastUpdate === null) { |
| 11888 | // One of the queues is not empty. We must add the update to both queues. |
| 11889 | appendUpdateToQueue(queue1, update); |
| 11890 | appendUpdateToQueue(queue2, update); |
| 11891 | } else { |
| 11892 | // Both queues are non-empty. The last update is the same in both lists, |
| 11893 | // because of structural sharing. So, only append to one of the lists. |
| 11894 | appendUpdateToQueue(queue1, update); |
| 11895 | // But we still need to update the `lastUpdate` pointer of queue2. |
| 11896 | queue2.lastUpdate = update; |
| 11897 | } |
| 11898 | } |
| 11899 | |
| 11900 | { |
| 11901 | if (fiber.tag === ClassComponent && (currentlyProcessingQueue === queue1 || queue2 !== null && currentlyProcessingQueue === queue2) && !didWarnUpdateInsideUpdate) { |
| 11902 | warningWithoutStack$1(false, 'An update (setState, replaceState, or forceUpdate) was scheduled ' + 'from inside an update function. Update functions should be pure, ' + 'with zero side-effects. Consider using componentDidUpdate or a ' + 'callback.'); |
| 11903 | didWarnUpdateInsideUpdate = true; |
no test coverage detected