( root: FiberRoot, fiber: Fiber, lane: Lane, )
| 914 | } |
| 915 | |
| 916 | export function scheduleUpdateOnFiber( |
| 917 | root: FiberRoot, |
| 918 | fiber: Fiber, |
| 919 | lane: Lane, |
| 920 | ) { |
| 921 | if (__DEV__) { |
| 922 | if (isRunningInsertionEffect) { |
| 923 | console.error('useInsertionEffect must not schedule updates.'); |
| 924 | } |
| 925 | } |
| 926 | |
| 927 | if (__DEV__) { |
| 928 | if (isFlushingPassiveEffects) { |
| 929 | didScheduleUpdateDuringPassiveEffects = true; |
| 930 | } |
| 931 | } |
| 932 | |
| 933 | // Check if the work loop is currently suspended and waiting for data to |
| 934 | // finish loading. |
| 935 | if ( |
| 936 | // Suspended render phase |
| 937 | (root === workInProgressRoot && |
| 938 | (workInProgressSuspendedReason === SuspendedOnData || |
| 939 | workInProgressSuspendedReason === SuspendedOnAction)) || |
| 940 | // Suspended commit phase |
| 941 | root.cancelPendingCommit !== null |
| 942 | ) { |
| 943 | // The incoming update might unblock the current render. Interrupt the |
| 944 | // current attempt and restart from the top. |
| 945 | prepareFreshStack(root, NoLanes); |
| 946 | const didAttemptEntireTree = false; |
| 947 | markRootSuspended( |
| 948 | root, |
| 949 | workInProgressRootRenderLanes, |
| 950 | workInProgressDeferredLane, |
| 951 | didAttemptEntireTree, |
| 952 | ); |
| 953 | } |
| 954 | |
| 955 | // Mark that the root has a pending update. |
| 956 | markRootUpdated(root, lane); |
| 957 | |
| 958 | if ( |
| 959 | (executionContext & RenderContext) !== NoContext && |
| 960 | root === workInProgressRoot |
| 961 | ) { |
| 962 | // This update was dispatched during the render phase. This is a mistake |
| 963 | // if the update originates from user space (with the exception of local |
| 964 | // hook updates, which are handled differently and don't reach this |
| 965 | // function), but there are some internal React features that use this as |
| 966 | // an implementation detail, like selective hydration. |
| 967 | warnAboutRenderPhaseUpdatesInDEV(fiber); |
| 968 | |
| 969 | // Track lanes that were updated during the render phase |
| 970 | workInProgressRootRenderPhaseUpdatedLanes = mergeLanes( |
| 971 | workInProgressRootRenderPhaseUpdatedLanes, |
| 972 | lane, |
| 973 | ); |
no test coverage detected