How to use pushContextProvider method in Playwright Internal

Best JavaScript code snippet using playwright-internal

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

ReactFiberContext.js

Source: ReactFiberContext.js Github

copy
1import { ClassComponent, HostRoot } from './ReactWorkTags';
2import { createCursor, push, pop } from './ReactFiberStack';
3
4const emptyContextObject = {};
5
6const contextStackCursor = createCursor(emptyContextObject);
7const didPerformWorkStackCursor = createCursor(false);
8
9let previousContext = emptyContextObject;
10
11const isContextProvider = (type) => {
12  const { childContextTypes } = type;
13  return childContextTypes !== null && childContextTypes !== undefined;
14};
15
16const popContext = (fiber) => {
17  pop(didPerformWorkStackCursor, fiber);
18  pop(contextStackCursor, fiber);
19};
20
21const findCurrentUnmaskedContext = (fiber) => {
22  let node = fiber;
23
24  do {
25    switch (node.tag) {
26      case HostRoot:
27        return node.stateNode.context;
28      case ClassComponent: {
29        const Component = node.type;
30        if (isContextProvider(Component)) {
31          return node.stateNode.__reactInternalMemoizedMergedChildContext;
32        }
33        break;
34      }
35    }
36    node = node.return;
37  } while (node !== null);
38};
39
40const processChildContext = (fiber, type, parentContext) => {
41  const instance = fiber.stateNode;
42
43  if (typeof instance.getChildContext !== 'function') return parentContext;
44
45  const childContext = instance.getChildContext();
46
47  return { ...parentContext, ...childContext };
48};
49
50const hasContextChanged = () => didPerformWorkStackCursor.current;
51
52const pushTopLevelContextObject = (fiber, context, didChange) => {
53  push(contextStackCursor, context, fiber);
54  push(didPerformWorkStackCursor, didChange, fiber);
55};
56
57const popTopLevelContextObject = (fiber) => {
58  pop(didPerformWorkStackCursor, fiber);
59  pop(contextStackCursor, fiber);
60};
61
62const pushContextProvider = (workInProgress) => {
63  const instance = workInProgress.stateNode;
64
65  const memoizedMergedChildContext =
66    (instance && instance.__reactInternalMemoizedMergedChildContext) ||
67    emptyContextObject;
68
69  previousContext = contextStackCursor.current;
70  push(contextStackCursor, memoizedMergedChildContext, workInProgress);
71  push(
72    didPerformWorkStackCursor,
73    didPerformWorkStackCursor.current,
74    workInProgress
75  );
76
77  return true;
78};
79
80const getUnmaskedContext = (
81  workInProgress,
82  Component,
83  didPushOwnContextIfProvider
84) => {
85  if (didPushOwnContextIfProvider && isContextProvider(Component)) {
86    return previousContext;
87  }
88  return contextStackCursor.current;
89};
90
91const cacheContext = (workInProgress, unmaskedContext, maskedContext) => {
92  const instance = workInProgress.stateNode;
93  instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
94  instance.__reactInternalMemoizedMaskedChildContext = maskedContext;
95};
96
97const getMaskedContext = (workInProgress, unmaskedContext) => {
98  const type = workInProgress.type;
99  const contextTypes = type.contextTypes;
100  if (!contextTypes) return emptyContextObject;
101
102  const instance = workInProgress.stateNode;
103  if (
104    instance &&
105    instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext
106  ) {
107    return instance.__reactInternalMemoizedMaskedChildContext;
108  }
109
110  const context = {};
111  for (const key in contextTypes) {
112    context[key] = unmaskedContext[key];
113  }
114
115  if (instance) {
116    cacheContext(workInProgress, unmaskedContext, context);
117  }
118
119  return context;
120};
121
122const invalidateContextProvider = (workInProgress, type, didChange) => {
123  const instance = workInProgress.stateNode;
124  invariant(
125    instance,
126    'Expected to have an instance by this point. ' +
127      'This error is likely caused by a bug in React. Please file an issue.'
128  );
129
130  if (didChange) {
131    const mergedContext = processChildContext(
132      workInProgress,
133      type,
134      previousContext
135    );
136    instance.__reactInternalMemoizedMergedChildContext = mergedContext;
137
138    pop(didPerformWorkStackCursor, workInProgress);
139    pop(contextStackCursor, workInProgress);
140
141    push(contextStackCursor, mergedContext, workInProgress);
142    push(didPerformWorkStackCursor, didChange, workInProgress);
143  } else {
144    pop(didPerformWorkStackCursor, workInProgress);
145    push(didPerformWorkStackCursor, didChange, workInProgress);
146  }
147};
148
149export {
150  emptyContextObject,
151  isContextProvider,
152  popContext,
153  findCurrentUnmaskedContext,
154  processChildContext,
155  hasContextChanged,
156  pushTopLevelContextObject,
157  popTopLevelContextObject,
158  pushContextProvider,
159  getUnmaskedContext,
160  getMaskedContext,
161  cacheContext,
162  invalidateContextProvider,
163};
164
Full Screen

b0ea876b301f63c96d702a493f5ebd456144bcReactFiberBeginWork.js

Source: b0ea876b301f63c96d702a493f5ebd456144bcReactFiberBeginWork.js Github

copy
1
2
3'use strict';
4
5var _require = require('ReactChildFiber'),
6    mountChildFibersInPlace = _require.mountChildFibersInPlace,
7    reconcileChildFibers = _require.reconcileChildFibers,
8    reconcileChildFibersInPlace = _require.reconcileChildFibersInPlace,
9    cloneChildFibers = _require.cloneChildFibers;
10
11var _require2 = require('ReactFiberUpdateQueue'),
12    beginUpdateQueue = _require2.beginUpdateQueue;
13
14var ReactTypeOfWork = require('ReactTypeOfWork');
15
16var _require3 = require('ReactFiberContext'),
17    getMaskedContext = _require3.getMaskedContext,
18    getUnmaskedContext = _require3.getUnmaskedContext,
19    hasContextChanged = _require3.hasContextChanged,
20    pushContextProvider = _require3.pushContextProvider,
21    pushTopLevelContextObject = _require3.pushTopLevelContextObject,
22    invalidateContextProvider = _require3.invalidateContextProvider;
23
24var IndeterminateComponent = ReactTypeOfWork.IndeterminateComponent,
25    FunctionalComponent = ReactTypeOfWork.FunctionalComponent,
26    ClassComponent = ReactTypeOfWork.ClassComponent,
27    HostRoot = ReactTypeOfWork.HostRoot,
28    HostComponent = ReactTypeOfWork.HostComponent,
29    HostText = ReactTypeOfWork.HostText,
30    HostPortal = ReactTypeOfWork.HostPortal,
31    CoroutineComponent = ReactTypeOfWork.CoroutineComponent,
32    CoroutineHandlerPhase = ReactTypeOfWork.CoroutineHandlerPhase,
33    YieldComponent = ReactTypeOfWork.YieldComponent,
34    Fragment = ReactTypeOfWork.Fragment;
35
36var _require4 = require('ReactPriorityLevel'),
37    NoWork = _require4.NoWork,
38    OffscreenPriority = _require4.OffscreenPriority;
39
40var _require5 = require('ReactTypeOfSideEffect'),
41    Placement = _require5.Placement,
42    ContentReset = _require5.ContentReset,
43    Err = _require5.Err,
44    Ref = _require5.Ref;
45
46var ReactCurrentOwner = require('react/lib/ReactCurrentOwner');
47var ReactFiberClassComponent = require('ReactFiberClassComponent');
48var invariant = require('fbjs/lib/invariant');
49
50if (__DEV__) {
51  var ReactDebugCurrentFiber = require('ReactDebugCurrentFiber');
52
53  var _require6 = require('ReactDebugFiberPerf'),
54      cancelWorkTimer = _require6.cancelWorkTimer;
55
56  var warning = require('fbjs/lib/warning');
57
58  var warnedAboutStatelessRefs = {};
59}
60
61module.exports = function (config, hostContext, scheduleUpdate, getPriorityContext) {
62  var shouldSetTextContent = config.shouldSetTextContent,
63      useSyncScheduling = config.useSyncScheduling,
64      shouldDeprioritizeSubtree = config.shouldDeprioritizeSubtree;
65  var pushHostContext = hostContext.pushHostContext,
66      pushHostContainer = hostContext.pushHostContainer;
67
68  var _ReactFiberClassCompo = ReactFiberClassComponent(scheduleUpdate, getPriorityContext, memoizeProps, memoizeState),
69      adoptClassInstance = _ReactFiberClassCompo.adoptClassInstance,
70      constructClassInstance = _ReactFiberClassCompo.constructClassInstance,
71      mountClassInstance = _ReactFiberClassCompo.mountClassInstance,
72      resumeMountClassInstance = _ReactFiberClassCompo.resumeMountClassInstance,
73      updateClassInstance = _ReactFiberClassCompo.updateClassInstance;
74
75  function markChildAsProgressed(current, workInProgress, priorityLevel) {
76    workInProgress.progressedChild = workInProgress.child;
77    workInProgress.progressedPriority = priorityLevel;
78    if (current !== null) {
79      current.progressedChild = workInProgress.progressedChild;
80      current.progressedPriority = workInProgress.progressedPriority;
81    }
82  }
83
84  function clearDeletions(workInProgress) {
85    workInProgress.progressedFirstDeletion = workInProgress.progressedLastDeletion = null;
86  }
87
88  function transferDeletions(workInProgress) {
89    workInProgress.firstEffect = workInProgress.progressedFirstDeletion;
90    workInProgress.lastEffect = workInProgress.progressedLastDeletion;
91  }
92
93  function reconcileChildren(current, workInProgress, nextChildren) {
94    var priorityLevel = workInProgress.pendingWorkPriority;
95    reconcileChildrenAtPriority(current, workInProgress, nextChildren, priorityLevel);
96  }
97
98  function reconcileChildrenAtPriority(current, workInProgress, nextChildren, priorityLevel) {
99    workInProgress.memoizedProps = null;
100    if (current === null) {
101      workInProgress.child = mountChildFibersInPlace(workInProgress, workInProgress.child, nextChildren, priorityLevel);
102    } else if (current.child === workInProgress.child) {
103      clearDeletions(workInProgress);
104
105      workInProgress.child = reconcileChildFibers(workInProgress, workInProgress.child, nextChildren, priorityLevel);
106
107      transferDeletions(workInProgress);
108    } else {
109      workInProgress.child = reconcileChildFibersInPlace(workInProgress, workInProgress.child, nextChildren, priorityLevel);
110
111      transferDeletions(workInProgress);
112    }
113    markChildAsProgressed(current, workInProgress, priorityLevel);
114  }
115
116  function updateFragment(current, workInProgress) {
117    var nextChildren = workInProgress.pendingProps;
118    if (hasContextChanged()) {
119      if (nextChildren === null) {
120        nextChildren = workInProgress.memoizedProps;
121      }
122    } else if (nextChildren === null || workInProgress.memoizedProps === nextChildren) {
123      return bailoutOnAlreadyFinishedWork(current, workInProgress);
124    }
125    reconcileChildren(current, workInProgress, nextChildren);
126    memoizeProps(workInProgress, nextChildren);
127    return workInProgress.child;
128  }
129
130  function markRef(current, workInProgress) {
131    var ref = workInProgress.ref;
132    if (ref !== null && (!current || current.ref !== ref)) {
133      workInProgress.effectTag |= Ref;
134    }
135  }
136
137  function updateFunctionalComponent(current, workInProgress) {
138    var fn = workInProgress.type;
139    var nextProps = workInProgress.pendingProps;
140
141    var memoizedProps = workInProgress.memoizedProps;
142    if (hasContextChanged()) {
143      if (nextProps === null) {
144        nextProps = memoizedProps;
145      }
146    } else {
147      if (nextProps === null || memoizedProps === nextProps) {
148        return bailoutOnAlreadyFinishedWork(current, workInProgress);
149      }
150
151      if (typeof fn.shouldComponentUpdate === 'function' && !fn.shouldComponentUpdate(memoizedProps, nextProps)) {
152        memoizeProps(workInProgress, nextProps);
153        return bailoutOnAlreadyFinishedWork(current, workInProgress);
154      }
155    }
156
157    var unmaskedContext = getUnmaskedContext(workInProgress);
158    var context = getMaskedContext(workInProgress, unmaskedContext);
159
160    var nextChildren;
161
162    if (__DEV__) {
163      ReactCurrentOwner.current = workInProgress;
164      ReactDebugCurrentFiber.phase = 'render';
165      nextChildren = fn(nextProps, context);
166      ReactDebugCurrentFiber.phase = null;
167    } else {
168      nextChildren = fn(nextProps, context);
169    }
170    reconcileChildren(current, workInProgress, nextChildren);
171    memoizeProps(workInProgress, nextProps);
172    return workInProgress.child;
173  }
174
175  function updateClassComponent(current, workInProgress, priorityLevel) {
176    var hasContext = pushContextProvider(workInProgress);
177
178    var shouldUpdate = void 0;
179    if (current === null) {
180      if (!workInProgress.stateNode) {
181        constructClassInstance(workInProgress);
182        mountClassInstance(workInProgress, priorityLevel);
183        shouldUpdate = true;
184      } else {
185        shouldUpdate = resumeMountClassInstance(workInProgress, priorityLevel);
186      }
187    } else {
188      shouldUpdate = updateClassInstance(current, workInProgress, priorityLevel);
189    }
190    return finishClassComponent(current, workInProgress, shouldUpdate, hasContext);
191  }
192
193  function finishClassComponent(current, workInProgress, shouldUpdate, hasContext) {
194    markRef(current, workInProgress);
195
196    if (!shouldUpdate) {
197      return bailoutOnAlreadyFinishedWork(current, workInProgress);
198    }
199
200    var instance = workInProgress.stateNode;
201
202    ReactCurrentOwner.current = workInProgress;
203    var nextChildren = void 0;
204    if (__DEV__) {
205      ReactDebugCurrentFiber.phase = 'render';
206      nextChildren = instance.render();
207      ReactDebugCurrentFiber.phase = null;
208    } else {
209      nextChildren = instance.render();
210    }
211    reconcileChildren(current, workInProgress, nextChildren);
212
213    memoizeState(workInProgress, instance.state);
214    memoizeProps(workInProgress, instance.props);
215
216    if (hasContext) {
217      invalidateContextProvider(workInProgress);
218    }
219    return workInProgress.child;
220  }
221
222  function updateHostRoot(current, workInProgress, priorityLevel) {
223    var root = workInProgress.stateNode;
224    if (root.pendingContext) {
225      pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context);
226    } else if (root.context) {
227      pushTopLevelContextObject(workInProgress, root.context, false);
228    }
229
230    pushHostContainer(workInProgress, root.containerInfo);
231
232    var updateQueue = workInProgress.updateQueue;
233    if (updateQueue !== null) {
234      var prevState = workInProgress.memoizedState;
235      var state = beginUpdateQueue(workInProgress, updateQueue, null, prevState, null, priorityLevel);
236      if (prevState === state) {
237        return bailoutOnAlreadyFinishedWork(current, workInProgress);
238      }
239      var element = state.element;
240      reconcileChildren(current, workInProgress, element);
241      memoizeState(workInProgress, state);
242      return workInProgress.child;
243    }
244
245    return bailoutOnAlreadyFinishedWork(current, workInProgress);
246  }
247
248  function updateHostComponent(current, workInProgress) {
249    pushHostContext(workInProgress);
250
251    var nextProps = workInProgress.pendingProps;
252    var prevProps = current !== null ? current.memoizedProps : null;
253    var memoizedProps = workInProgress.memoizedProps;
254    if (hasContextChanged()) {
255      if (nextProps === null) {
256        nextProps = memoizedProps;
257        invariant(nextProps !== null, 'We should always have pending or current props. This error is ' + 'likely caused by a bug in React. Please file an issue.');
258      }
259    } else if (nextProps === null || memoizedProps === nextProps) {
260      if (!useSyncScheduling && shouldDeprioritizeSubtree(workInProgress.type, memoizedProps) && workInProgress.pendingWorkPriority !== OffscreenPriority) {
261        var child = workInProgress.progressedChild;
262        while (child !== null) {
263          child.pendingWorkPriority = OffscreenPriority;
264          child = child.sibling;
265        }
266        return null;
267      }
268      return bailoutOnAlreadyFinishedWork(current, workInProgress);
269    }
270
271    var nextChildren = nextProps.children;
272    var isDirectTextChild = shouldSetTextContent(nextProps);
273
274    if (isDirectTextChild) {
275      nextChildren = null;
276    } else if (prevProps && shouldSetTextContent(prevProps)) {
277      workInProgress.effectTag |= ContentReset;
278    }
279
280    markRef(current, workInProgress);
281
282    if (!useSyncScheduling && shouldDeprioritizeSubtree(workInProgress.type, nextProps) && workInProgress.pendingWorkPriority !== OffscreenPriority) {
283
284      if (workInProgress.progressedPriority === OffscreenPriority) {
285        workInProgress.child = workInProgress.progressedChild;
286      }
287
288      reconcileChildrenAtPriority(current, workInProgress, nextChildren, OffscreenPriority);
289      memoizeProps(workInProgress, nextProps);
290      workInProgress.child = current !== null ? current.child : null;
291
292      if (current === null) {
293        var _child = workInProgress.progressedChild;
294        while (_child !== null) {
295          _child.effectTag = Placement;
296          _child = _child.sibling;
297        }
298      }
299
300      return null;
301    } else {
302      reconcileChildren(current, workInProgress, nextChildren);
303      memoizeProps(workInProgress, nextProps);
304      return workInProgress.child;
305    }
306  }
307
308  function updateHostText(current, workInProgress) {
309    var nextProps = workInProgress.pendingProps;
310    if (nextProps === null) {
311      nextProps = workInProgress.memoizedProps;
312    }
313    memoizeProps(workInProgress, nextProps);
314
315    return null;
316  }
317
318  function mountIndeterminateComponent(current, workInProgress, priorityLevel) {
319    invariant(current === null, 'An indeterminate component should never have mounted. This error is ' + 'likely caused by a bug in React. Please file an issue.');
320    var fn = workInProgress.type;
321    var props = workInProgress.pendingProps;
322    var unmaskedContext = getUnmaskedContext(workInProgress);
323    var context = getMaskedContext(workInProgress, unmaskedContext);
324
325    var value;
326
327    if (__DEV__) {
328      ReactCurrentOwner.current = workInProgress;
329      value = fn(props, context);
330    } else {
331      value = fn(props, context);
332    }
333
334    if (typeof value === 'object' && value !== null && typeof value.render === 'function') {
335      workInProgress.tag = ClassComponent;
336
337      var hasContext = pushContextProvider(workInProgress);
338      adoptClassInstance(workInProgress, value);
339      mountClassInstance(workInProgress, priorityLevel);
340      return finishClassComponent(current, workInProgress, true, hasContext);
341    } else {
342      workInProgress.tag = FunctionalComponent;
343      if (__DEV__) {
344        var Component = workInProgress.type;
345
346        if (Component) {
347          warning(!Component.childContextTypes, '%s(...): childContextTypes cannot be defined on a functional component.', Component.displayName || Component.name || 'Component');
348        }
349        if (workInProgress.ref !== null) {
350          var info = '';
351          var ownerName = ReactDebugCurrentFiber.getCurrentFiberOwnerName();
352          if (ownerName) {
353            info += '\n\nCheck the render method of `' + ownerName + '`.';
354          }
355
356          var warningKey = ownerName || workInProgress._debugID || '';
357          var debugSource = workInProgress._debugSource;
358          if (debugSource) {
359            warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
360          }
361          if (!warnedAboutStatelessRefs[warningKey]) {
362            warnedAboutStatelessRefs[warningKey] = true;
363            warning(false, 'Stateless function components cannot be given refs. ' + 'Attempts to access this ref will fail.%s%s', info, ReactDebugCurrentFiber.getCurrentFiberStackAddendum());
364          }
365        }
366      }
367      reconcileChildren(current, workInProgress, value);
368      memoizeProps(workInProgress, props);
369      return workInProgress.child;
370    }
371  }
372
373  function updateCoroutineComponent(current, workInProgress) {
374    var nextCoroutine = workInProgress.pendingProps;
375    if (hasContextChanged()) {
376      if (nextCoroutine === null) {
377        nextCoroutine = current && current.memoizedProps;
378        invariant(nextCoroutine !== null, 'We should always have pending or current props. This error is ' + 'likely caused by a bug in React. Please file an issue.');
379      }
380    } else if (nextCoroutine === null || workInProgress.memoizedProps === nextCoroutine) {
381      nextCoroutine = workInProgress.memoizedProps;
382    }
383
384    var nextChildren = nextCoroutine.children;
385    var priorityLevel = workInProgress.pendingWorkPriority;
386
387    workInProgress.memoizedProps = null;
388    if (current === null) {
389      workInProgress.stateNode = mountChildFibersInPlace(workInProgress, workInProgress.stateNode, nextChildren, priorityLevel);
390    } else if (current.child === workInProgress.child) {
391      clearDeletions(workInProgress);
392
393      workInProgress.stateNode = reconcileChildFibers(workInProgress, workInProgress.stateNode, nextChildren, priorityLevel);
394
395      transferDeletions(workInProgress);
396    } else {
397      workInProgress.stateNode = reconcileChildFibersInPlace(workInProgress, workInProgress.stateNode, nextChildren, priorityLevel);
398
399      transferDeletions(workInProgress);
400    }
401
402    memoizeProps(workInProgress, nextCoroutine);
403
404    return workInProgress.stateNode;
405  }
406
407  function updatePortalComponent(current, workInProgress) {
408    pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
409    var priorityLevel = workInProgress.pendingWorkPriority;
410    var nextChildren = workInProgress.pendingProps;
411    if (hasContextChanged()) {
412      if (nextChildren === null) {
413        nextChildren = current && current.memoizedProps;
414        invariant(nextChildren != null, 'We should always have pending or current props. This error is ' + 'likely caused by a bug in React. Please file an issue.');
415      }
416    } else if (nextChildren === null || workInProgress.memoizedProps === nextChildren) {
417      return bailoutOnAlreadyFinishedWork(current, workInProgress);
418    }
419
420    if (current === null) {
421      workInProgress.child = reconcileChildFibersInPlace(workInProgress, workInProgress.child, nextChildren, priorityLevel);
422      memoizeProps(workInProgress, nextChildren);
423      markChildAsProgressed(current, workInProgress, priorityLevel);
424    } else {
425      reconcileChildren(current, workInProgress, nextChildren);
426      memoizeProps(workInProgress, nextChildren);
427    }
428    return workInProgress.child;
429  }
430
431  function bailoutOnAlreadyFinishedWork(current, workInProgress) {
432    if (__DEV__) {
433      cancelWorkTimer(workInProgress);
434    }
435
436    var priorityLevel = workInProgress.pendingWorkPriority;
437
438
439    if (current && workInProgress.child === current.child) {
440      clearDeletions(workInProgress);
441    }
442
443    cloneChildFibers(current, workInProgress);
444    markChildAsProgressed(current, workInProgress, priorityLevel);
445    return workInProgress.child;
446  }
447
448  function bailoutOnLowPriority(current, workInProgress) {
449    if (__DEV__) {
450      cancelWorkTimer(workInProgress);
451    }
452
453    switch (workInProgress.tag) {
454      case ClassComponent:
455        pushContextProvider(workInProgress);
456        break;
457      case HostPortal:
458        pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
459        break;
460    }
461
462    return null;
463  }
464
465  function memoizeProps(workInProgress, nextProps) {
466    workInProgress.memoizedProps = nextProps;
467
468    workInProgress.pendingProps = null;
469  }
470
471  function memoizeState(workInProgress, nextState) {
472    workInProgress.memoizedState = nextState;
473  }
474
475  function beginWork(current, workInProgress, priorityLevel) {
476    if (workInProgress.pendingWorkPriority === NoWork || workInProgress.pendingWorkPriority > priorityLevel) {
477      return bailoutOnLowPriority(current, workInProgress);
478    }
479
480    if (__DEV__) {
481      ReactDebugCurrentFiber.current = workInProgress;
482    }
483
484    workInProgress.firstEffect = null;
485    workInProgress.lastEffect = null;
486
487    if (workInProgress.progressedPriority === priorityLevel) {
488      workInProgress.child = workInProgress.progressedChild;
489    }
490
491    switch (workInProgress.tag) {
492      case IndeterminateComponent:
493        return mountIndeterminateComponent(current, workInProgress, priorityLevel);
494      case FunctionalComponent:
495        return updateFunctionalComponent(current, workInProgress);
496      case ClassComponent:
497        return updateClassComponent(current, workInProgress, priorityLevel);
498      case HostRoot:
499        return updateHostRoot(current, workInProgress, priorityLevel);
500      case HostComponent:
501        return updateHostComponent(current, workInProgress);
502      case HostText:
503        return updateHostText(current, workInProgress);
504      case CoroutineHandlerPhase:
505        workInProgress.tag = CoroutineComponent;
506
507      case CoroutineComponent:
508        return updateCoroutineComponent(current, workInProgress);
509      case YieldComponent:
510        return null;
511      case HostPortal:
512        return updatePortalComponent(current, workInProgress);
513      case Fragment:
514        return updateFragment(current, workInProgress);
515      default:
516        invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in ' + 'React. Please file an issue.');
517    }
518  }
519
520  function beginFailedWork(current, workInProgress, priorityLevel) {
521    invariant(workInProgress.tag === ClassComponent || workInProgress.tag === HostRoot, 'Invalid type of work. This error is likely caused by a bug in React. ' + 'Please file an issue.');
522
523    workInProgress.effectTag |= Err;
524
525    if (workInProgress.pendingWorkPriority === NoWork || workInProgress.pendingWorkPriority > priorityLevel) {
526      return bailoutOnLowPriority(current, workInProgress);
527    }
528
529    workInProgress.firstEffect = null;
530    workInProgress.lastEffect = null;
531
532    var nextChildren = null;
533    reconcileChildren(current, workInProgress, nextChildren);
534
535    if (workInProgress.tag === ClassComponent) {
536      var instance = workInProgress.stateNode;
537      workInProgress.memoizedProps = instance.props;
538      workInProgress.memoizedState = instance.state;
539      workInProgress.pendingProps = null;
540    }
541
542    return workInProgress.child;
543  }
544
545  return {
546    beginWork: beginWork,
547    beginFailedWork: beginFailedWork
548  };
549};
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Playwright Internal on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)