MCPcopy
hub / github.com/facebook/react / createWorkInProgressHook

Function createWorkInProgressHook

packages/react-server/src/ReactFizzHooks.js:182–205  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

180}
181
182function createWorkInProgressHook(): Hook {
183 if (workInProgressHook === null) {
184 // This is the first hook in the list
185 if (firstWorkInProgressHook === null) {
186 isReRender = false;
187 firstWorkInProgressHook = workInProgressHook = createHook();
188 } else {
189 // There's already a work-in-progress. Reuse it.
190 isReRender = true;
191 workInProgressHook = firstWorkInProgressHook;
192 }
193 } else {
194 if (workInProgressHook.next === null) {
195 isReRender = false;
196 // Append to the end of the list
197 workInProgressHook = workInProgressHook.next = createHook();
198 } else {
199 // There's already a work-in-progress. Reuse it.
200 isReRender = true;
201 workInProgressHook = workInProgressHook.next;
202 }
203 }
204 return workInProgressHook;
205}
206
207export function prepareToUseHooks(
208 request: Request,

Callers 3

useReducerFunction · 0.85
useMemoFunction · 0.85
useRefFunction · 0.85

Calls 1

createHookFunction · 0.70

Tested by

no test coverage detected