MCPcopy Index your code
hub / github.com/microsoft/SandDance / updateWorkInProgressHook

Function updateWorkInProgressHook

docs/external/js/react-dom.development.js:15078–15138  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15076 }
15077
15078 function updateWorkInProgressHook() {
15079 // This function is used both for updates and for re-renders triggered by a
15080 // render phase update. It assumes there is either a current hook we can
15081 // clone, or a work-in-progress hook from a previous render pass that we can
15082 // use as a base. When we reach the end of the base list, we must switch to
15083 // the dispatcher used for mounts.
15084 var nextCurrentHook;
15085
15086 if (currentHook === null) {
15087 var current = currentlyRenderingFiber$1.alternate;
15088
15089 if (current !== null) {
15090 nextCurrentHook = current.memoizedState;
15091 } else {
15092 nextCurrentHook = null;
15093 }
15094 } else {
15095 nextCurrentHook = currentHook.next;
15096 }
15097
15098 var nextWorkInProgressHook;
15099
15100 if (workInProgressHook === null) {
15101 nextWorkInProgressHook = currentlyRenderingFiber$1.memoizedState;
15102 } else {
15103 nextWorkInProgressHook = workInProgressHook.next;
15104 }
15105
15106 if (nextWorkInProgressHook !== null) {
15107 // There's already a work-in-progress. Reuse it.
15108 workInProgressHook = nextWorkInProgressHook;
15109 nextWorkInProgressHook = workInProgressHook.next;
15110 currentHook = nextCurrentHook;
15111 } else {
15112 // Clone from the current hook.
15113 if (!(nextCurrentHook !== null)) {
15114 {
15115 throw Error( "Rendered more hooks than during the previous render." );
15116 }
15117 }
15118
15119 currentHook = nextCurrentHook;
15120 var newHook = {
15121 memoizedState: currentHook.memoizedState,
15122 baseState: currentHook.baseState,
15123 baseQueue: currentHook.baseQueue,
15124 queue: currentHook.queue,
15125 next: null
15126 };
15127
15128 if (workInProgressHook === null) {
15129 // This is the first hook in the list.
15130 currentlyRenderingFiber$1.memoizedState = workInProgressHook = newHook;
15131 } else {
15132 // Append to the end of the list.
15133 workInProgressHook = workInProgressHook.next = newHook;
15134 }
15135 }

Callers 6

updateReducerFunction · 0.85
rerenderReducerFunction · 0.85
updateRefFunction · 0.85
updateEffectImplFunction · 0.85
updateCallbackFunction · 0.85
updateMemoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected