MCPcopy Create free account
hub / github.com/QuarkGluonPlasma/react-course-code / run

Function run

mini-react/src/mini-react.js:319–343  ·  view source on GitHub ↗
(fiber)

Source from the content-addressed store, hash-verified

317 }
318
319 function run(fiber) {
320 if (!fiber) return;
321
322 fiber.effectHooks?.forEach((newHook, index) => {
323 if(!fiber.alternate) {
324 newHook.cleanup = newHook.callback();
325 return;
326 }
327
328 if(!newHook.deps) {
329 newHook.cleanup = newHook.callback();
330 }
331
332 if (newHook.deps.length > 0) {
333 const oldHook = fiber.alternate?.effectHooks[index];
334
335 if(!isDepsEqual(oldHook.deps, newHook.deps)) {
336 newHook.cleanup = newHook.callback()
337 }
338 }
339 });
340
341 run(fiber.child);
342 run(fiber.sibling);
343 }
344
345 runCleanup(wipRoot);
346 run(wipRoot);

Callers 1

commitEffectHooksFunction · 0.85

Calls 1

isDepsEqualFunction · 0.85

Tested by

no test coverage detected