Best JavaScript code snippet using playwright-internal
ReactFiberBeginWork.new.js
Source:ReactFiberBeginWork.new.js
...2518// pass through beginWork to rerender all children (including the tail) with2519// the force suspend context. If the first render didn't have anything in2520// in fallback state. Then we render each row in the tail one-by-one.2521// That happens in the completeWork phase without going back to beginWork.2522function updateSuspenseListComponent(2523 current: Fiber | null,2524 workInProgress: Fiber,2525 renderLanes: Lanes,2526) {2527 const nextProps = workInProgress.pendingProps;2528 const revealOrder: SuspenseListRevealOrder = nextProps.revealOrder;2529 const tailMode: SuspenseListTailMode = nextProps.tail;2530 const newChildren = nextProps.children;2531 validateRevealOrder(revealOrder);2532 validateTailOptions(tailMode, revealOrder);2533 validateSuspenseListChildren(newChildren, revealOrder);2534 reconcileChildren(current, workInProgress, newChildren, renderLanes);2535 let suspenseContext: SuspenseContext = suspenseStackCursor.current;2536 const shouldForceFallback = hasSuspenseContext(2537 suspenseContext,2538 (ForceSuspenseFallback: SuspenseContext),2539 );2540 if (shouldForceFallback) {2541 suspenseContext = setShallowSuspenseContext(2542 suspenseContext,2543 ForceSuspenseFallback,2544 );2545 workInProgress.flags |= DidCapture;2546 } else {2547 const didSuspendBefore =2548 current !== null && (current.flags & DidCapture) !== NoFlags;2549 if (didSuspendBefore) {2550 // If we previously forced a fallback, we need to schedule work2551 // on any nested boundaries to let them know to try to render2552 // again. This is the same as context updating.2553 propagateSuspenseContextChange(2554 workInProgress,2555 workInProgress.child,2556 renderLanes,2557 );2558 }2559 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);2560 }2561 pushSuspenseContext(workInProgress, suspenseContext);2562 if ((workInProgress.mode & BlockingMode) === NoMode) {2563 // In legacy mode, SuspenseList doesn't work so we just2564 // use make it a noop by treating it as the default revealOrder.2565 workInProgress.memoizedState = null;2566 } else {2567 switch (revealOrder) {2568 case 'forwards': {2569 const lastContentRow = findLastContentRow(workInProgress.child);2570 let tail;2571 if (lastContentRow === null) {2572 // The whole list is part of the tail.2573 // TODO: We could fast path by just rendering the tail now.2574 tail = workInProgress.child;2575 workInProgress.child = null;2576 } else {2577 // Disconnect the tail rows after the content row.2578 // We're going to render them separately later.2579 tail = lastContentRow.sibling;2580 lastContentRow.sibling = null;2581 }2582 initSuspenseListRenderState(2583 workInProgress,2584 false, // isBackwards2585 tail,2586 lastContentRow,2587 tailMode,2588 );2589 break;2590 }2591 case 'backwards': {2592 // We're going to find the first row that has existing content.2593 // At the same time we're going to reverse the list of everything2594 // we pass in the meantime. That's going to be our tail in reverse2595 // order.2596 let tail = null;2597 let row = workInProgress.child;2598 workInProgress.child = null;2599 while (row !== null) {2600 const currentRow = row.alternate;2601 // New rows can't be content rows.2602 if (currentRow !== null && findFirstSuspended(currentRow) === null) {2603 // This is the beginning of the main content.2604 workInProgress.child = row;2605 break;2606 }2607 const nextRow = row.sibling;2608 row.sibling = tail;2609 tail = row;2610 row = nextRow;2611 }2612 // TODO: If workInProgress.child is null, we can continue on the tail immediately.2613 initSuspenseListRenderState(2614 workInProgress,2615 true, // isBackwards2616 tail,2617 null, // last2618 tailMode,2619 );2620 break;2621 }2622 case 'together': {2623 initSuspenseListRenderState(2624 workInProgress,2625 false, // isBackwards2626 null, // tail2627 null, // last2628 undefined,2629 );2630 break;2631 }2632 default: {2633 // The default reveal order is the same as not having2634 // a boundary.2635 workInProgress.memoizedState = null;2636 }2637 }2638 }2639 return workInProgress.child;2640}2641function updatePortalComponent(2642 current: Fiber | null,2643 workInProgress: Fiber,2644 renderLanes: Lanes,2645) {2646 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);2647 const nextChildren = workInProgress.pendingProps;2648 if (current === null) {2649 // Portals are special because we don't append the children during mount2650 // but at commit. Therefore we need to track insertions which the normal2651 // flow doesn't do during mount. This doesn't happen at the root because2652 // the root always starts with a "current" with a null child.2653 // TODO: Consider unifying this with how the root works.2654 workInProgress.child = reconcileChildFibers(2655 workInProgress,2656 null,2657 nextChildren,2658 renderLanes,2659 );2660 } else {2661 reconcileChildren(current, workInProgress, nextChildren, renderLanes);2662 }2663 return workInProgress.child;2664}2665let hasWarnedAboutUsingNoValuePropOnContextProvider = false;2666function updateContextProvider(2667 current: Fiber | null,2668 workInProgress: Fiber,2669 renderLanes: Lanes,2670) {2671 const providerType: ReactProviderType<any> = workInProgress.type;2672 const context: ReactContext<any> = providerType._context;2673 const newProps = workInProgress.pendingProps;2674 const oldProps = workInProgress.memoizedProps;2675 const newValue = newProps.value;2676 if (__DEV__) {2677 if (!('value' in newProps)) {2678 if (!hasWarnedAboutUsingNoValuePropOnContextProvider) {2679 hasWarnedAboutUsingNoValuePropOnContextProvider = true;2680 console.error(2681 'The `value` prop is required for the `<Context.Provider>`. Did you misspell it or forget to pass it?',2682 );2683 }2684 }2685 const providerPropTypes = workInProgress.type.propTypes;2686 if (providerPropTypes) {2687 checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider');2688 }2689 }2690 pushProvider(workInProgress, newValue);2691 if (oldProps !== null) {2692 const oldValue = oldProps.value;2693 const changedBits = calculateChangedBits(context, newValue, oldValue);2694 if (changedBits === 0) {2695 // No change. Bailout early if children are the same.2696 if (2697 oldProps.children === newProps.children &&2698 !hasLegacyContextChanged()2699 ) {2700 return bailoutOnAlreadyFinishedWork(2701 current,2702 workInProgress,2703 renderLanes,2704 );2705 }2706 } else {2707 // The context value changed. Search for matching consumers and schedule2708 // them to update.2709 propagateContextChange(workInProgress, context, changedBits, renderLanes);2710 }2711 }2712 const newChildren = newProps.children;2713 reconcileChildren(current, workInProgress, newChildren, renderLanes);2714 return workInProgress.child;2715}2716let hasWarnedAboutUsingContextAsConsumer = false;2717function updateContextConsumer(2718 current: Fiber | null,2719 workInProgress: Fiber,2720 renderLanes: Lanes,2721) {2722 let context: ReactContext<any> = workInProgress.type;2723 // The logic below for Context differs depending on PROD or DEV mode. In2724 // DEV mode, we create a separate object for Context.Consumer that acts2725 // like a proxy to Context. This proxy object adds unnecessary code in PROD2726 // so we use the old behaviour (Context.Consumer references Context) to2727 // reduce size and overhead. The separate object references context via2728 // a property called "_context", which also gives us the ability to check2729 // in DEV mode if this property exists or not and warn if it does not.2730 if (__DEV__) {2731 if ((context: any)._context === undefined) {2732 // This may be because it's a Context (rather than a Consumer).2733 // Or it may be because it's older React where they're the same thing.2734 // We only want to warn if we're sure it's a new React.2735 if (context !== context.Consumer) {2736 if (!hasWarnedAboutUsingContextAsConsumer) {2737 hasWarnedAboutUsingContextAsConsumer = true;2738 console.error(2739 'Rendering <Context> directly is not supported and will be removed in ' +2740 'a future major release. Did you mean to render <Context.Consumer> instead?',2741 );2742 }2743 }2744 } else {2745 context = (context: any)._context;2746 }2747 }2748 const newProps = workInProgress.pendingProps;2749 const render = newProps.children;2750 if (__DEV__) {2751 if (typeof render !== 'function') {2752 console.error(2753 'A context consumer was rendered with multiple children, or a child ' +2754 "that isn't a function. A context consumer expects a single child " +2755 'that is a function. If you did pass a function, make sure there ' +2756 'is no trailing or leading whitespace around it.',2757 );2758 }2759 }2760 prepareToReadContext(workInProgress, renderLanes);2761 const newValue = readContext(context, newProps.unstable_observedBits);2762 let newChildren;2763 if (__DEV__) {2764 ReactCurrentOwner.current = workInProgress;2765 setIsRendering(true);2766 newChildren = render(newValue);2767 setIsRendering(false);2768 } else {2769 newChildren = render(newValue);2770 }2771 // React DevTools reads this flag.2772 workInProgress.flags |= PerformedWork;2773 reconcileChildren(current, workInProgress, newChildren, renderLanes);2774 return workInProgress.child;2775}2776function updateFundamentalComponent(current, workInProgress, renderLanes) {2777 const fundamentalImpl = workInProgress.type.impl;2778 if (fundamentalImpl.reconcileChildren === false) {2779 return null;2780 }2781 const nextProps = workInProgress.pendingProps;2782 const nextChildren = nextProps.children;2783 reconcileChildren(current, workInProgress, nextChildren, renderLanes);2784 return workInProgress.child;2785}2786function updateScopeComponent(current, workInProgress, renderLanes) {2787 const nextProps = workInProgress.pendingProps;2788 const nextChildren = nextProps.children;2789 reconcileChildren(current, workInProgress, nextChildren, renderLanes);2790 return workInProgress.child;2791}2792export function markWorkInProgressReceivedUpdate() {2793 didReceiveUpdate = true;2794}2795function bailoutOnAlreadyFinishedWork(2796 current: Fiber | null,2797 workInProgress: Fiber,2798 renderLanes: Lanes,2799): Fiber | null {2800 if (current !== null) {2801 // Reuse previous dependencies2802 workInProgress.dependencies = current.dependencies;2803 }2804 if (enableProfilerTimer) {2805 // Don't update "base" render times for bailouts.2806 stopProfilerTimerIfRunning(workInProgress);2807 }2808 markSkippedUpdateLanes(workInProgress.lanes);2809 // Check if the children have any pending work.2810 if (!includesSomeLane(renderLanes, workInProgress.childLanes)) {2811 // The children don't have any work either. We can skip them.2812 // TODO: Once we add back resuming, we should check if the children are2813 // a work-in-progress set. If so, we need to transfer their effects.2814 return null;2815 } else {2816 // This fiber doesn't have work, but its subtree does. Clone the child2817 // fibers and continue.2818 cloneChildFibers(current, workInProgress);2819 return workInProgress.child;2820 }2821}2822function remountFiber(2823 current: Fiber,2824 oldWorkInProgress: Fiber,2825 newWorkInProgress: Fiber,2826): Fiber | null {2827 if (__DEV__) {2828 const returnFiber = oldWorkInProgress.return;2829 if (returnFiber === null) {2830 throw new Error('Cannot swap the root fiber.');2831 }2832 // Disconnect from the old current.2833 // It will get deleted.2834 current.alternate = null;2835 oldWorkInProgress.alternate = null;2836 // Connect to the new tree.2837 newWorkInProgress.index = oldWorkInProgress.index;2838 newWorkInProgress.sibling = oldWorkInProgress.sibling;2839 newWorkInProgress.return = oldWorkInProgress.return;2840 newWorkInProgress.ref = oldWorkInProgress.ref;2841 // Replace the child/sibling pointers above it.2842 if (oldWorkInProgress === returnFiber.child) {2843 returnFiber.child = newWorkInProgress;2844 } else {2845 let prevSibling = returnFiber.child;2846 if (prevSibling === null) {2847 throw new Error('Expected parent to have a child.');2848 }2849 while (prevSibling.sibling !== oldWorkInProgress) {2850 prevSibling = prevSibling.sibling;2851 if (prevSibling === null) {2852 throw new Error('Expected to find the previous sibling.');2853 }2854 }2855 prevSibling.sibling = newWorkInProgress;2856 }2857 // Delete the old fiber and place the new one.2858 // Since the old fiber is disconnected, we have to schedule it manually.2859 const deletions = returnFiber.deletions;2860 if (deletions === null) {2861 returnFiber.deletions = [current];2862 // TODO (effects) Rename this to better reflect its new usage (e.g. ChildDeletions)2863 returnFiber.flags |= Deletion;2864 } else {2865 deletions.push(current);2866 }2867 newWorkInProgress.flags |= Placement;2868 // Restart work from the new fiber.2869 return newWorkInProgress;2870 } else {2871 throw new Error(2872 'Did not expect this call in production. ' +2873 'This is a bug in React. Please file an issue.',2874 );2875 }2876}2877function beginWork(2878 current: Fiber | null,2879 workInProgress: Fiber,2880 renderLanes: Lanes,2881): Fiber | null {2882 const updateLanes = workInProgress.lanes;2883 if (__DEV__) {2884 if (workInProgress._debugNeedsRemount && current !== null) {2885 // This will restart the begin phase with a new fiber.2886 return remountFiber(2887 current,2888 workInProgress,2889 createFiberFromTypeAndProps(2890 workInProgress.type,2891 workInProgress.key,2892 workInProgress.pendingProps,2893 workInProgress._debugOwner || null,2894 workInProgress.mode,2895 workInProgress.lanes,2896 ),2897 );2898 }2899 }2900 if (current !== null) {2901 const oldProps = current.memoizedProps;2902 const newProps = workInProgress.pendingProps;2903 if (2904 oldProps !== newProps ||2905 hasLegacyContextChanged() ||2906 // Force a re-render if the implementation changed due to hot reload:2907 (__DEV__ ? workInProgress.type !== current.type : false)2908 ) {2909 // If props or context changed, mark the fiber as having performed work.2910 // This may be unset if the props are determined to be equal later (memo).2911 didReceiveUpdate = true;2912 } else if (!includesSomeLane(renderLanes, updateLanes)) {2913 didReceiveUpdate = false;2914 // This fiber does not have any pending work. Bailout without entering2915 // the begin phase. There's still some bookkeeping we that needs to be done2916 // in this optimized path, mostly pushing stuff onto the stack.2917 switch (workInProgress.tag) {2918 case HostRoot:2919 pushHostRootContext(workInProgress);2920 resetHydrationState();2921 break;2922 case HostComponent:2923 pushHostContext(workInProgress);2924 break;2925 case ClassComponent: {2926 const Component = workInProgress.type;2927 if (isLegacyContextProvider(Component)) {2928 pushLegacyContextProvider(workInProgress);2929 }2930 break;2931 }2932 case HostPortal:2933 pushHostContainer(2934 workInProgress,2935 workInProgress.stateNode.containerInfo,2936 );2937 break;2938 case ContextProvider: {2939 const newValue = workInProgress.memoizedProps.value;2940 pushProvider(workInProgress, newValue);2941 break;2942 }2943 case Profiler:2944 if (enableProfilerTimer) {2945 // Reset effect durations for the next eventual effect phase.2946 // These are reset during render to allow the DevTools commit hook a chance to read them,2947 const stateNode = workInProgress.stateNode;2948 stateNode.effectDuration = 0;2949 stateNode.passiveEffectDuration = 0;2950 }2951 break;2952 case SuspenseComponent: {2953 const state: SuspenseState | null = workInProgress.memoizedState;2954 if (state !== null) {2955 if (enableSuspenseServerRenderer) {2956 if (state.dehydrated !== null) {2957 pushSuspenseContext(2958 workInProgress,2959 setDefaultShallowSuspenseContext(suspenseStackCursor.current),2960 );2961 // We know that this component will suspend again because if it has2962 // been unsuspended it has committed as a resolved Suspense component.2963 // If it needs to be retried, it should have work scheduled on it.2964 workInProgress.flags |= DidCapture;2965 // We should never render the children of a dehydrated boundary until we2966 // upgrade it. We return null instead of bailoutOnAlreadyFinishedWork.2967 return null;2968 }2969 }2970 // If this boundary is currently timed out, we need to decide2971 // whether to retry the primary children, or to skip over it and2972 // go straight to the fallback. Check the priority of the primary2973 // child fragment.2974 const primaryChildFragment: Fiber = (workInProgress.child: any);2975 const primaryChildLanes = primaryChildFragment.childLanes;2976 if (includesSomeLane(renderLanes, primaryChildLanes)) {2977 // The primary children have pending work. Use the normal path2978 // to attempt to render the primary children again.2979 return updateSuspenseComponent(2980 current,2981 workInProgress,2982 renderLanes,2983 );2984 } else {2985 // The primary child fragment does not have pending work marked2986 // on it2987 pushSuspenseContext(2988 workInProgress,2989 setDefaultShallowSuspenseContext(suspenseStackCursor.current),2990 );2991 // The primary children do not have pending work with sufficient2992 // priority. Bailout.2993 const child = bailoutOnAlreadyFinishedWork(2994 current,2995 workInProgress,2996 renderLanes,2997 );2998 if (child !== null) {2999 // The fallback children have pending work. Skip over the3000 // primary children and work on the fallback.3001 return child.sibling;3002 } else {3003 return null;3004 }3005 }3006 } else {3007 pushSuspenseContext(3008 workInProgress,3009 setDefaultShallowSuspenseContext(suspenseStackCursor.current),3010 );3011 }3012 break;3013 }3014 case SuspenseListComponent: {3015 const didSuspendBefore = (current.flags & DidCapture) !== NoFlags;3016 const hasChildWork = includesSomeLane(3017 renderLanes,3018 workInProgress.childLanes,3019 );3020 if (didSuspendBefore) {3021 if (hasChildWork) {3022 // If something was in fallback state last time, and we have all the3023 // same children then we're still in progressive loading state.3024 // Something might get unblocked by state updates or retries in the3025 // tree which will affect the tail. So we need to use the normal3026 // path to compute the correct tail.3027 return updateSuspenseListComponent(3028 current,3029 workInProgress,3030 renderLanes,3031 );3032 }3033 // If none of the children had any work, that means that none of3034 // them got retried so they'll still be blocked in the same way3035 // as before. We can fast bail out.3036 workInProgress.flags |= DidCapture;3037 }3038 // If nothing suspended before and we're rendering the same children,3039 // then the tail doesn't matter. Anything new that suspends will work3040 // in the "together" mode, so we can continue from the state we had.3041 const renderState = workInProgress.memoizedState;3042 if (renderState !== null) {3043 // Reset to the "together" mode in case we've started a different3044 // update in the past but didn't complete it.3045 renderState.rendering = null;3046 renderState.tail = null;3047 }3048 pushSuspenseContext(workInProgress, suspenseStackCursor.current);3049 if (hasChildWork) {3050 break;3051 } else {3052 // If none of the children had any work, that means that none of3053 // them got retried so they'll still be blocked in the same way3054 // as before. We can fast bail out.3055 return null;3056 }3057 }3058 case OffscreenComponent:3059 case LegacyHiddenComponent: {3060 // Need to check if the tree still needs to be deferred. This is3061 // almost identical to the logic used in the normal update path,3062 // so we'll just enter that. The only difference is we'll bail out3063 // at the next level instead of this one, because the child props3064 // have not changed. Which is fine.3065 // TODO: Probably should refactor `beginWork` to split the bailout3066 // path from the normal path. I'm tempted to do a labeled break here3067 // but I won't :)3068 workInProgress.lanes = NoLanes;3069 return updateOffscreenComponent(current, workInProgress, renderLanes);3070 }3071 }3072 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);3073 } else {3074 if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) {3075 // This is a special case that only exists for legacy mode.3076 // See https://github.com/facebook/react/pull/19216.3077 didReceiveUpdate = true;3078 } else {3079 // An update was scheduled on this fiber, but there are no new props3080 // nor legacy context. Set this to false. If an update queue or context3081 // consumer produces a changed value, it will set this to true. Otherwise,3082 // the component will assume the children have not changed and bail out.3083 didReceiveUpdate = false;3084 }3085 }3086 } else {3087 didReceiveUpdate = false;3088 }3089 // Before entering the begin phase, clear pending update priority.3090 // TODO: This assumes that we're about to evaluate the component and process3091 // the update queue. However, there's an exception: SimpleMemoComponent3092 // sometimes bails out later in the begin phase. This indicates that we should3093 // move this assignment out of the common path and into each branch.3094 workInProgress.lanes = NoLanes;3095 switch (workInProgress.tag) {3096 case IndeterminateComponent: {3097 return mountIndeterminateComponent(3098 current,3099 workInProgress,3100 workInProgress.type,3101 renderLanes,3102 );3103 }3104 case LazyComponent: {3105 const elementType = workInProgress.elementType;3106 return mountLazyComponent(3107 current,3108 workInProgress,3109 elementType,3110 updateLanes,3111 renderLanes,3112 );3113 }3114 case FunctionComponent: {3115 const Component = workInProgress.type;3116 const unresolvedProps = workInProgress.pendingProps;3117 const resolvedProps =3118 workInProgress.elementType === Component3119 ? unresolvedProps3120 : resolveDefaultProps(Component, unresolvedProps);3121 return updateFunctionComponent(3122 current,3123 workInProgress,3124 Component,3125 resolvedProps,3126 renderLanes,3127 );3128 }3129 case ClassComponent: {3130 const Component = workInProgress.type;3131 const unresolvedProps = workInProgress.pendingProps;3132 const resolvedProps =3133 workInProgress.elementType === Component3134 ? unresolvedProps3135 : resolveDefaultProps(Component, unresolvedProps);3136 return updateClassComponent(3137 current,3138 workInProgress,3139 Component,3140 resolvedProps,3141 renderLanes,3142 );3143 }3144 case HostRoot:3145 return updateHostRoot(current, workInProgress, renderLanes);3146 case HostComponent:3147 return updateHostComponent(current, workInProgress, renderLanes);3148 case HostText:3149 return updateHostText(current, workInProgress);3150 case SuspenseComponent:3151 return updateSuspenseComponent(current, workInProgress, renderLanes);3152 case HostPortal:3153 return updatePortalComponent(current, workInProgress, renderLanes);3154 case ForwardRef: {3155 const type = workInProgress.type;3156 const unresolvedProps = workInProgress.pendingProps;3157 const resolvedProps =3158 workInProgress.elementType === type3159 ? unresolvedProps3160 : resolveDefaultProps(type, unresolvedProps);3161 return updateForwardRef(3162 current,3163 workInProgress,3164 type,3165 resolvedProps,3166 renderLanes,3167 );3168 }3169 case Fragment:3170 return updateFragment(current, workInProgress, renderLanes);3171 case Mode:3172 return updateMode(current, workInProgress, renderLanes);3173 case Profiler:3174 return updateProfiler(current, workInProgress, renderLanes);3175 case ContextProvider:3176 return updateContextProvider(current, workInProgress, renderLanes);3177 case ContextConsumer:3178 return updateContextConsumer(current, workInProgress, renderLanes);3179 case MemoComponent: {3180 const type = workInProgress.type;3181 const unresolvedProps = workInProgress.pendingProps;3182 // Resolve outer props first, then resolve inner props.3183 let resolvedProps = resolveDefaultProps(type, unresolvedProps);3184 if (__DEV__) {3185 if (workInProgress.type !== workInProgress.elementType) {3186 const outerPropTypes = type.propTypes;3187 if (outerPropTypes) {3188 checkPropTypes(3189 outerPropTypes,3190 resolvedProps, // Resolved for outer only3191 'prop',3192 getComponentName(type),3193 );3194 }3195 }3196 }3197 resolvedProps = resolveDefaultProps(type.type, resolvedProps);3198 return updateMemoComponent(3199 current,3200 workInProgress,3201 type,3202 resolvedProps,3203 updateLanes,3204 renderLanes,3205 );3206 }3207 case SimpleMemoComponent: {3208 return updateSimpleMemoComponent(3209 current,3210 workInProgress,3211 workInProgress.type,3212 workInProgress.pendingProps,3213 updateLanes,3214 renderLanes,3215 );3216 }3217 case IncompleteClassComponent: {3218 const Component = workInProgress.type;3219 const unresolvedProps = workInProgress.pendingProps;3220 const resolvedProps =3221 workInProgress.elementType === Component3222 ? unresolvedProps3223 : resolveDefaultProps(Component, unresolvedProps);3224 return mountIncompleteClassComponent(3225 current,3226 workInProgress,3227 Component,3228 resolvedProps,3229 renderLanes,3230 );3231 }3232 case SuspenseListComponent: {3233 return updateSuspenseListComponent(current, workInProgress, renderLanes);3234 }3235 case FundamentalComponent: {3236 if (enableFundamentalAPI) {3237 return updateFundamentalComponent(current, workInProgress, renderLanes);3238 }3239 break;3240 }3241 case ScopeComponent: {3242 if (enableScopeAPI) {3243 return updateScopeComponent(current, workInProgress, renderLanes);3244 }3245 break;3246 }3247 case Block: {...
ReactFiberBeginWork.old.js
Source:ReactFiberBeginWork.old.js
...1477 // pass through beginWork to rerender all children (including the tail) with1478 // the force suspend context. If the first render didn't have anything in1479 // in fallback state. Then we render each row in the tail one-by-one.1480 // That happens in the completeWork phase without going back to beginWork.1481 function updateSuspenseListComponent(current, workInProgress, renderLanes) {1482 var nextProps = workInProgress.pendingProps;1483 var revealOrder = nextProps.revealOrder;1484 var tailMode = nextProps.tail;1485 var newChildren = nextProps.children;1486 validateRevealOrder(revealOrder);1487 validateTailOptions(tailMode, revealOrder);1488 validateSuspenseListChildren(newChildren, revealOrder);1489 reconcileChildren(current, workInProgress, newChildren, renderLanes);1490 var suspenseContext = suspenseStackCursor.current;1491 var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback);1492 if (shouldForceFallback) {1493 suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);1494 workInProgress.flags |= DidCapture;1495 } else {1496 var didSuspendBefore = current !== null && (current.flags & DidCapture) !== NoFlags;1497 if (didSuspendBefore) {1498 // If we previously forced a fallback, we need to schedule work1499 // on any nested boundaries to let them know to try to render1500 // again. This is the same as context updating.1501 propagateSuspenseContextChange(workInProgress, workInProgress.child, renderLanes);1502 }1503 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);1504 }1505 pushSuspenseContext(workInProgress, suspenseContext);1506 if ((workInProgress.mode & BlockingMode) === NoMode) {1507 // In legacy mode, SuspenseList doesn't work so we just1508 // use make it a noop by treating it as the default revealOrder.1509 workInProgress.memoizedState = null;1510 } else {1511 switch (revealOrder) {1512 case 'forwards':1513 {1514 var lastContentRow = findLastContentRow(workInProgress.child);1515 var tail;1516 if (lastContentRow === null) {1517 // The whole list is part of the tail.1518 // TODO: We could fast path by just rendering the tail now.1519 tail = workInProgress.child;1520 workInProgress.child = null;1521 } else {1522 // Disconnect the tail rows after the content row.1523 // We're going to render them separately later.1524 tail = lastContentRow.sibling;1525 lastContentRow.sibling = null;1526 }1527 initSuspenseListRenderState(workInProgress, false, // isBackwards1528 tail, lastContentRow, tailMode, workInProgress.lastEffect);1529 break;1530 }1531 case 'backwards':1532 {1533 // We're going to find the first row that has existing content.1534 // At the same time we're going to reverse the list of everything1535 // we pass in the meantime. That's going to be our tail in reverse1536 // order.1537 var _tail = null;1538 var row = workInProgress.child;1539 workInProgress.child = null;1540 while (row !== null) {1541 var currentRow = row.alternate; // New rows can't be content rows.1542 if (currentRow !== null && findFirstSuspended(currentRow) === null) {1543 // This is the beginning of the main content.1544 workInProgress.child = row;1545 break;1546 }1547 var nextRow = row.sibling;1548 row.sibling = _tail;1549 _tail = row;1550 row = nextRow;1551 } // TODO: If workInProgress.child is null, we can continue on the tail immediately.1552 initSuspenseListRenderState(workInProgress, true, // isBackwards1553 _tail, null, // last1554 tailMode, workInProgress.lastEffect);1555 break;1556 }1557 case 'together':1558 {1559 initSuspenseListRenderState(workInProgress, false, // isBackwards1560 null, // tail1561 null, // last1562 undefined, workInProgress.lastEffect);1563 break;1564 }1565 default:1566 {1567 // The default reveal order is the same as not having1568 // a boundary.1569 workInProgress.memoizedState = null;1570 }1571 }1572 }1573 return workInProgress.child;1574 }1575 function updatePortalComponent(current, workInProgress, renderLanes) {1576 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);1577 var nextChildren = workInProgress.pendingProps;1578 if (current === null) {1579 // Portals are special because we don't append the children during mount1580 // but at commit. Therefore we need to track insertions which the normal1581 // flow doesn't do during mount. This doesn't happen at the root because1582 // the root always starts with a "current" with a null child.1583 // TODO: Consider unifying this with how the root works.1584 workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderLanes);1585 } else {1586 reconcileChildren(current, workInProgress, nextChildren, renderLanes);1587 }1588 return workInProgress.child;1589 }1590 var hasWarnedAboutUsingNoValuePropOnContextProvider = false;1591 function updateContextProvider(current, workInProgress, renderLanes) {1592 var providerType = workInProgress.type;1593 var context = providerType._context;1594 var newProps = workInProgress.pendingProps;1595 var oldProps = workInProgress.memoizedProps;1596 var newValue = newProps.value;1597 {1598 if (!('value' in newProps)) {1599 if (!hasWarnedAboutUsingNoValuePropOnContextProvider) {1600 hasWarnedAboutUsingNoValuePropOnContextProvider = true;1601 error('The `value` prop is required for the `<Context.Provider>`. Did you misspell it or forget to pass it?');1602 }1603 }1604 var providerPropTypes = workInProgress.type.propTypes;1605 if (providerPropTypes) {1606 checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider');1607 }1608 }1609 pushProvider(workInProgress, newValue);1610 if (oldProps !== null) {1611 var oldValue = oldProps.value;1612 var changedBits = calculateChangedBits(context, newValue, oldValue);1613 if (changedBits === 0) {1614 // No change. Bailout early if children are the same.1615 if (oldProps.children === newProps.children && !hasContextChanged()) {1616 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);1617 }1618 } else {1619 // The context value changed. Search for matching consumers and schedule1620 // them to update.1621 propagateContextChange(workInProgress, context, changedBits, renderLanes);1622 }1623 }1624 var newChildren = newProps.children;1625 reconcileChildren(current, workInProgress, newChildren, renderLanes);1626 return workInProgress.child;1627 }1628 var hasWarnedAboutUsingContextAsConsumer = false;1629 function updateContextConsumer(current, workInProgress, renderLanes) {1630 var context = workInProgress.type; // The logic below for Context differs depending on PROD or DEV mode. In1631 // DEV mode, we create a separate object for Context.Consumer that acts1632 // like a proxy to Context. This proxy object adds unnecessary code in PROD1633 // so we use the old behaviour (Context.Consumer references Context) to1634 // reduce size and overhead. The separate object references context via1635 // a property called "_context", which also gives us the ability to check1636 // in DEV mode if this property exists or not and warn if it does not.1637 {1638 if (context._context === undefined) {1639 // This may be because it's a Context (rather than a Consumer).1640 // Or it may be because it's older React where they're the same thing.1641 // We only want to warn if we're sure it's a new React.1642 if (context !== context.Consumer) {1643 if (!hasWarnedAboutUsingContextAsConsumer) {1644 hasWarnedAboutUsingContextAsConsumer = true;1645 error('Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');1646 }1647 }1648 } else {1649 context = context._context;1650 }1651 }1652 var newProps = workInProgress.pendingProps;1653 var render = newProps.children;1654 {1655 if (typeof render !== 'function') {1656 error('A context consumer was rendered with multiple children, or a child ' + "that isn't a function. A context consumer expects a single child " + 'that is a function. If you did pass a function, make sure there ' + 'is no trailing or leading whitespace around it.');1657 }1658 }1659 prepareToReadContext(workInProgress, renderLanes);1660 var newValue = readContext(context, newProps.unstable_observedBits);1661 var newChildren;1662 {1663 ReactCurrentOwner$1.current = workInProgress;1664 setIsRendering(true);1665 newChildren = render(newValue);1666 setIsRendering(false);1667 } // React DevTools reads this flag.1668 workInProgress.flags |= PerformedWork;1669 reconcileChildren(current, workInProgress, newChildren, renderLanes);1670 return workInProgress.child;1671 }1672 function markWorkInProgressReceivedUpdate() {1673 didReceiveUpdate = true;1674 }1675 function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) {1676 if (current !== null) {1677 // Reuse previous dependencies1678 workInProgress.dependencies = current.dependencies;1679 }1680 {1681 // Don't update "base" render times for bailouts.1682 stopProfilerTimerIfRunning();1683 }1684 markSkippedUpdateLanes(workInProgress.lanes); // Check if the children have any pending work.1685 if (!includesSomeLane(renderLanes, workInProgress.childLanes)) {1686 // The children don't have any work either. We can skip them.1687 // TODO: Once we add back resuming, we should check if the children are1688 // a work-in-progress set. If so, we need to transfer their effects.1689 return null;1690 } else {1691 // This fiber doesn't have work, but its subtree does. Clone the child1692 // fibers and continue.1693 cloneChildFibers(current, workInProgress);1694 return workInProgress.child;1695 }1696 }1697 function remountFiber(current, oldWorkInProgress, newWorkInProgress) {1698 {1699 var returnFiber = oldWorkInProgress.return;1700 if (returnFiber === null) {1701 throw new Error('Cannot swap the root fiber.');1702 } // Disconnect from the old current.1703 // It will get deleted.1704 current.alternate = null;1705 oldWorkInProgress.alternate = null; // Connect to the new tree.1706 newWorkInProgress.index = oldWorkInProgress.index;1707 newWorkInProgress.sibling = oldWorkInProgress.sibling;1708 newWorkInProgress.return = oldWorkInProgress.return;1709 newWorkInProgress.ref = oldWorkInProgress.ref; // Replace the child/sibling pointers above it.1710 if (oldWorkInProgress === returnFiber.child) {1711 returnFiber.child = newWorkInProgress;1712 } else {1713 var prevSibling = returnFiber.child;1714 if (prevSibling === null) {1715 throw new Error('Expected parent to have a child.');1716 }1717 while (prevSibling.sibling !== oldWorkInProgress) {1718 prevSibling = prevSibling.sibling;1719 if (prevSibling === null) {1720 throw new Error('Expected to find the previous sibling.');1721 }1722 }1723 prevSibling.sibling = newWorkInProgress;1724 } // Delete the old fiber and place the new one.1725 // Since the old fiber is disconnected, we have to schedule it manually.1726 var last = returnFiber.lastEffect;1727 if (last !== null) {1728 last.nextEffect = current;1729 returnFiber.lastEffect = current;1730 } else {1731 returnFiber.firstEffect = returnFiber.lastEffect = current;1732 }1733 current.nextEffect = null;1734 current.flags = Deletion;1735 newWorkInProgress.flags |= Placement; // Restart work from the new fiber.1736 return newWorkInProgress;1737 }1738 }1739 function beginWork(current, workInProgress, renderLanes) {1740 var updateLanes = workInProgress.lanes;1741 {1742 if (workInProgress._debugNeedsRemount && current !== null) {1743 // This will restart the begin phase with a new fiber.1744 return remountFiber(current, workInProgress, createFiberFromTypeAndProps(workInProgress.type, workInProgress.key, workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, workInProgress.lanes));1745 }1746 }1747 if (current !== null) {1748 var oldProps = current.memoizedProps;1749 var newProps = workInProgress.pendingProps;1750 if (oldProps !== newProps || hasContextChanged() || ( // Force a re-render if the implementation changed due to hot reload:1751 workInProgress.type !== current.type )) {1752 // If props or context changed, mark the fiber as having performed work.1753 // This may be unset if the props are determined to be equal later (memo).1754 didReceiveUpdate = true;1755 } else if (!includesSomeLane(renderLanes, updateLanes)) {1756 didReceiveUpdate = false; // This fiber does not have any pending work. Bailout without entering1757 // the begin phase. There's still some bookkeeping we that needs to be done1758 // in this optimized path, mostly pushing stuff onto the stack.1759 switch (workInProgress.tag) {1760 case HostRoot:1761 pushHostRootContext(workInProgress);1762 resetHydrationState();1763 break;1764 case HostComponent:1765 pushHostContext(workInProgress);1766 break;1767 case ClassComponent:1768 {1769 var Component = workInProgress.type;1770 if (isContextProvider(Component)) {1771 pushContextProvider(workInProgress);1772 }1773 break;1774 }1775 case HostPortal:1776 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);1777 break;1778 case ContextProvider:1779 {1780 var newValue = workInProgress.memoizedProps.value;1781 pushProvider(workInProgress, newValue);1782 break;1783 }1784 case Profiler:1785 {1786 // Profiler should only call onRender when one of its descendants actually rendered.1787 var hasChildWork = includesSomeLane(renderLanes, workInProgress.childLanes);1788 if (hasChildWork) {1789 workInProgress.flags |= Update;1790 } // Reset effect durations for the next eventual effect phase.1791 // These are reset during render to allow the DevTools commit hook a chance to read them,1792 var stateNode = workInProgress.stateNode;1793 stateNode.effectDuration = 0;1794 stateNode.passiveEffectDuration = 0;1795 }1796 break;1797 case SuspenseComponent:1798 {1799 var state = workInProgress.memoizedState;1800 if (state !== null) {1801 {1802 if (state.dehydrated !== null) {1803 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); // We know that this component will suspend again because if it has1804 // been unsuspended it has committed as a resolved Suspense component.1805 // If it needs to be retried, it should have work scheduled on it.1806 workInProgress.flags |= DidCapture; // We should never render the children of a dehydrated boundary until we1807 // upgrade it. We return null instead of bailoutOnAlreadyFinishedWork.1808 return null;1809 }1810 } // If this boundary is currently timed out, we need to decide1811 // whether to retry the primary children, or to skip over it and1812 // go straight to the fallback. Check the priority of the primary1813 // child fragment.1814 var primaryChildFragment = workInProgress.child;1815 var primaryChildLanes = primaryChildFragment.childLanes;1816 if (includesSomeLane(renderLanes, primaryChildLanes)) {1817 // The primary children have pending work. Use the normal path1818 // to attempt to render the primary children again.1819 return updateSuspenseComponent(current, workInProgress, renderLanes);1820 } else {1821 // The primary child fragment does not have pending work marked1822 // on it1823 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); // The primary children do not have pending work with sufficient1824 // priority. Bailout.1825 var child = bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);1826 if (child !== null) {1827 // The fallback children have pending work. Skip over the1828 // primary children and work on the fallback.1829 return child.sibling;1830 } else {1831 return null;1832 }1833 }1834 } else {1835 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));1836 }1837 break;1838 }1839 case SuspenseListComponent:1840 {1841 var didSuspendBefore = (current.flags & DidCapture) !== NoFlags;1842 var _hasChildWork = includesSomeLane(renderLanes, workInProgress.childLanes);1843 if (didSuspendBefore) {1844 if (_hasChildWork) {1845 // If something was in fallback state last time, and we have all the1846 // same children then we're still in progressive loading state.1847 // Something might get unblocked by state updates or retries in the1848 // tree which will affect the tail. So we need to use the normal1849 // path to compute the correct tail.1850 return updateSuspenseListComponent(current, workInProgress, renderLanes);1851 } // If none of the children had any work, that means that none of1852 // them got retried so they'll still be blocked in the same way1853 // as before. We can fast bail out.1854 workInProgress.flags |= DidCapture;1855 } // If nothing suspended before and we're rendering the same children,1856 // then the tail doesn't matter. Anything new that suspends will work1857 // in the "together" mode, so we can continue from the state we had.1858 var renderState = workInProgress.memoizedState;1859 if (renderState !== null) {1860 // Reset to the "together" mode in case we've started a different1861 // update in the past but didn't complete it.1862 renderState.rendering = null;1863 renderState.tail = null;1864 renderState.lastEffect = null;1865 }1866 pushSuspenseContext(workInProgress, suspenseStackCursor.current);1867 if (_hasChildWork) {1868 break;1869 } else {1870 // If none of the children had any work, that means that none of1871 // them got retried so they'll still be blocked in the same way1872 // as before. We can fast bail out.1873 return null;1874 }1875 }1876 case OffscreenComponent:1877 case LegacyHiddenComponent:1878 {1879 // Need to check if the tree still needs to be deferred. This is1880 // almost identical to the logic used in the normal update path,1881 // so we'll just enter that. The only difference is we'll bail out1882 // at the next level instead of this one, because the child props1883 // have not changed. Which is fine.1884 // TODO: Probably should refactor `beginWork` to split the bailout1885 // path from the normal path. I'm tempted to do a labeled break here1886 // but I won't :)1887 workInProgress.lanes = NoLanes;1888 return updateOffscreenComponent(current, workInProgress, renderLanes);1889 }1890 }1891 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);1892 } else {1893 if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) {1894 // This is a special case that only exists for legacy mode.1895 // See https://github.com/facebook/react/pull/19216.1896 didReceiveUpdate = true;1897 } else {1898 // An update was scheduled on this fiber, but there are no new props1899 // nor legacy context. Set this to false. If an update queue or context1900 // consumer produces a changed value, it will set this to true. Otherwise,1901 // the component will assume the children have not changed and bail out.1902 didReceiveUpdate = false;1903 }1904 }1905 } else {1906 didReceiveUpdate = false;1907 } // Before entering the begin phase, clear pending update priority.1908 // TODO: This assumes that we're about to evaluate the component and process1909 // the update queue. However, there's an exception: SimpleMemoComponent1910 // sometimes bails out later in the begin phase. This indicates that we should1911 // move this assignment out of the common path and into each branch.1912 workInProgress.lanes = NoLanes;1913 switch (workInProgress.tag) {1914 case IndeterminateComponent:1915 {1916 return mountIndeterminateComponent(current, workInProgress, workInProgress.type, renderLanes);1917 }1918 case LazyComponent:1919 {1920 var elementType = workInProgress.elementType;1921 return mountLazyComponent(current, workInProgress, elementType, updateLanes, renderLanes);1922 }1923 case FunctionComponent:1924 {1925 var _Component = workInProgress.type;1926 var unresolvedProps = workInProgress.pendingProps;1927 var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps);1928 return updateFunctionComponent(current, workInProgress, _Component, resolvedProps, renderLanes);1929 }1930 case ClassComponent:1931 {1932 var _Component2 = workInProgress.type;1933 var _unresolvedProps = workInProgress.pendingProps;1934 var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps);1935 return updateClassComponent(current, workInProgress, _Component2, _resolvedProps, renderLanes);1936 }1937 case HostRoot:1938 return updateHostRoot(current, workInProgress, renderLanes);1939 case HostComponent:1940 return updateHostComponent(current, workInProgress, renderLanes);1941 case HostText:1942 return updateHostText(current, workInProgress);1943 case SuspenseComponent:1944 return updateSuspenseComponent(current, workInProgress, renderLanes);1945 case HostPortal:1946 return updatePortalComponent(current, workInProgress, renderLanes);1947 case ForwardRef:1948 {1949 var type = workInProgress.type;1950 var _unresolvedProps2 = workInProgress.pendingProps;1951 var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);1952 return updateForwardRef(current, workInProgress, type, _resolvedProps2, renderLanes);1953 }1954 case Fragment:1955 return updateFragment(current, workInProgress, renderLanes);1956 case Mode:1957 return updateMode(current, workInProgress, renderLanes);1958 case Profiler:1959 return updateProfiler(current, workInProgress, renderLanes);1960 case ContextProvider:1961 return updateContextProvider(current, workInProgress, renderLanes);1962 case ContextConsumer:1963 return updateContextConsumer(current, workInProgress, renderLanes);1964 case MemoComponent:1965 {1966 var _type2 = workInProgress.type;1967 var _unresolvedProps3 = workInProgress.pendingProps; // Resolve outer props first, then resolve inner props.1968 var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);1969 {1970 if (workInProgress.type !== workInProgress.elementType) {1971 var outerPropTypes = _type2.propTypes;1972 if (outerPropTypes) {1973 checkPropTypes(outerPropTypes, _resolvedProps3, // Resolved for outer only1974 'prop', getComponentName(_type2));1975 }1976 }1977 }1978 _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);1979 return updateMemoComponent(current, workInProgress, _type2, _resolvedProps3, updateLanes, renderLanes);1980 }1981 case SimpleMemoComponent:1982 {1983 return updateSimpleMemoComponent(current, workInProgress, workInProgress.type, workInProgress.pendingProps, updateLanes, renderLanes);1984 }1985 case IncompleteClassComponent:1986 {1987 var _Component3 = workInProgress.type;1988 var _unresolvedProps4 = workInProgress.pendingProps;1989 var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);1990 return mountIncompleteClassComponent(current, workInProgress, _Component3, _resolvedProps4, renderLanes);1991 }1992 case SuspenseListComponent:1993 {1994 return updateSuspenseListComponent(current, workInProgress, renderLanes);1995 }1996 case FundamentalComponent:1997 {1998 break;1999 }2000 case ScopeComponent:2001 {2002 break;2003 }2004 case Block:2005 {2006 {2007 var block = workInProgress.type;2008 var props = workInProgress.pendingProps;...
ReactFiberBeginWork.js
Source:ReactFiberBeginWork.js
...170 // same children then we're still in progressive loading state.171 // Something might get unblocked by state updates or retries in the172 // tree which will affect the tail. So we need to use the normal173 // path to compute the correct tail.174 return updateSuspenseListComponent(175 current,176 workInProgress,177 renderLanes178 );179 }180 // If none of the children had any work, that means that none of181 // them got retried so they'll still be blocked in the same way182 // as before. We can fast bail out.183 workInProgress.flags |= DidCapture;184 }185 // If nothing suspended before and we're rendering the same children,186 // then the tail doesn't matter. Anything new that suspends will work187 // in the "together" mode, so we can continue from the state we had.188 const renderState = workInProgress.memoizedState;189 if (renderState !== null) {190 // Reset to the "together" mode in case we've started a different191 // update in the past but didn't complete it.192 renderState.rendering = null;193 renderState.tail = null;194 renderState.lastEffect = null;195 }196 pushSuspenseContext(workInProgress, suspenseStackCursor.current);197 if (hasChildWork) {198 break;199 } else {200 // If none of the children had any work, that means that none of201 // them got retried so they'll still be blocked in the same way202 // as before. We can fast bail out.203 return null;204 }205 break;206 case OffscreenComponent:207 case LegacyHiddenComponent:208 // Need to check if the tree still needs to be deferred. This is209 // almost identical to the logic used in the normal update path,210 // so we'll just enter that. The only difference is we'll bail out211 // at the next level instead of this one, because the child props212 // have not changed. Which is fine.213 // TODO: Probably should refactor `beginWork` to split the bailout214 // path from the normal path. I'm tempted to do a labeled break here215 // but I won't :)216 workInProgress.lanes = NoLanes;217 return updateOffscreenComponent(current, workInProgress, renderLanes);218 }219 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);220 } else {221 // flagsæ è¯å¯ä½ç¨222 // é¦æ¬¡æ¸²æcurrent.flagsåºè¯¥æ¯ NoFlags = 0223 if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) {224 // æä½ä¸è¿ç®ç»æä¸ä¸º0ï¼ ä¹å°±æ¯è¯´current.flagsè¯å®å
å«ForceUpdateForLegacySuspense225 // This is a special case that only exists for legacy mode.226 // See https://github.com/facebook/react/pull/19216.227 didReceiveUpdate = true;228 } else {229 // å次渲æèµ°è¿æ¡230 // An update was scheduled on this fiber, but there are no new props231 // nor legacy context. Set this to false. If an update queue or context232 // consumer produces a changed value, it will set this to true. Otherwise,233 // the component will assume the children have not changed and bail out.234 didReceiveUpdate = false;235 }236 }237 } else {238 didReceiveUpdate = false;239 }240 // Before entering the begin phase, clear pending update priority.241 // TODO: This assumes that we're about to evaluate the component and process242 // the update queue. However, there's an exception: SimpleMemoComponent243 // sometimes bails out later in the begin phase. This indicates that we should244 // move this assignment out of the common path and into each branch.245 // ææ¶ä¸æç½ä¸ºä½è¦æ¸
é¤WIPçlanes246 workInProgress.lanes = NoLanes;247 // å次渲æï¼ ç¬¬ä¸æ¬¡loopï¼ è¿éçwipåºè¯¥æ¯ host fiber root, tag 为 HostRoot = 3248 // å次渲æï¼ ç¬¬äºæ¬¡loopï¼ è¿éçwipåºè¯¥æ¯ 项ç®åºç¨æ ¹èç¹ï¼ å¨æå¦ä¹ çååä¸ä¸º<App>, tag 为 IndeterminateComponent = 2249 switch (workInProgress.tag) {250 case IndeterminateComponent: {251 // æç»è¿åçæ¯<App>ä¸ç第ä¸ä¸ªchildèç¹, ä¸ä¸ªHTMLDivELementèç¹252 return mountIndeterminateComponent(253 current,254 workInProgress,255 workInProgress.type,256 renderLanes257 );258 }259 case LazyComponent: {260 const elementType = workInProgress.elementType;261 return mountLazyComponent(262 current,263 workInProgress,264 elementType,265 updateLanes,266 renderLanes267 );268 }269 case FunctionComponent: {270 const Component = workInProgress.type;271 const unresolvedProps = workInProgress.pendingProps;272 const resolvedProps =273 workInProgress.elementType === Component274 ? unresolvedProps275 : resolveDefaultProps(Component, unresolvedProps);276 return updateFunctionComponent(277 current,278 workInProgress,279 Component,280 resolvedProps,281 renderLanes282 );283 }284 case ClassComponent: {285 const Component = workInProgress.type;286 const unresolvedProps = workInProgress.pendingProps;287 const resolvedProps =288 workInProgress.elementType === Component289 ? unresolvedProps290 : resolveDefaultProps(Component, unresolvedProps);291 return updateClassComponent(292 current,293 workInProgress,294 Component,295 resolvedProps,296 renderLanes297 );298 }299 case HostRoot:300 return updateHostRoot(current, workInProgress, renderLanes);301 case HostComponent:302 return updateHostComponent(current, workInProgress, renderLanes);303 case HostText:304 return updateHostText(current, workInProgress);305 case SuspenseComponent:306 return updateSuspenseComponent(current, workInProgress, renderLanes);307 case HostPortal:308 return updatePortalComponent(current, workInProgress, renderLanes);309 case ForwardRef: {310 const type = workInProgress.type;311 const unresolvedProps = workInProgress.pendingProps;312 const resolvedProps =313 workInProgress.elementType === type314 ? unresolvedProps315 : resolveDefaultProps(type, unresolvedProps);316 return updateForwardRef(317 current,318 workInProgress,319 type,320 resolvedProps,321 renderLanes322 );323 }324 case Fragment:325 return updateFragment(current, workInProgress, renderLanes);326 case Mode:327 return updateMode(current, workInProgress, renderLanes);328 case Profiler:329 return updateProfiler(current, workInProgress, renderLanes);330 case ContextProvider:331 return updateContextProvider(current, workInProgress, renderLanes);332 case ContextConsumer:333 return updateContextConsumer(current, workInProgress, renderLanes);334 case MemoComponent: {335 const type = workInProgress.type;336 const unresolvedProps = workInProgress.pendingProps;337 // Resolve outer props first, then resolve inner props.338 let resolvedProps = resolveDefaultProps(type, unresolvedProps);339 resolvedProps = resolveDefaultProps(type.type, resolvedProps);340 return updateMemoComponent(341 current,342 workInProgress,343 type,344 resolvedProps,345 updateLanes,346 renderLanes347 );348 }349 case SimpleMemoComponent: {350 return updateSimpleMemoComponent(351 current,352 workInProgress,353 workInProgress.type,354 workInProgress.pendingProps,355 updateLanes,356 renderLanes357 );358 }359 case IncompleteClassComponent: {360 const Component = workInProgress.type;361 const unresolvedProps = workInProgress.pendingProps;362 const resolvedProps =363 workInProgress.elementType === Component364 ? unresolvedProps365 : resolveDefaultProps(Component, unresolvedProps);366 return mountIncompleteClassComponent(367 current,368 workInProgress,369 Component,370 resolvedProps,371 renderLanes372 );373 }374 case SuspenseListComponent: {375 return updateSuspenseListComponent(current, workInProgress, renderLanes);376 }377 case FundamentalComponent: {378 if (enableFundamentalAPI) {379 return updateFundamentalComponent(current, workInProgress, renderLanes);380 }381 break;382 }383 case ScopeComponent: {384 if (enableScopeAPI) {385 return updateScopeComponent(current, workInProgress, renderLanes);386 }387 break;388 }389 case Block: {...
0__index.js
Source:0__index.js
...100 // same children then we're still in progressive loading state.101 // Something might get unblocked by state updates or retries in the102 // tree which will affect the tail. So we need to use the normal103 // path to compute the correct tail.104 return updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime);105 } // If none of the children had any work, that means that none of106 // them got retried so they'll still be blocked in the same way107 // as before. We can fast bail out.108 workInProgress.effectTag |= DidCapture;109 } // If nothing suspended before and we're rendering the same children,110 // then the tail doesn't matter. Anything new that suspends will work111 // in the "together" mode, so we can continue from the state we had.112 var renderState = workInProgress.memoizedState;113 if (renderState !== null) {114 // Reset to the "together" mode in case we've started a different115 // update in the past but didn't complete it.116 renderState.rendering = null;117 renderState.tail = null;118 }119 pushSuspenseContext(workInProgress, suspenseStackCursor.current);120 if (hasChildWork) {121 break;122 } else {123 // If none of the children had any work, that means that none of124 // them got retried so they'll still be blocked in the same way125 // as before. We can fast bail out.126 return null;127 }128 }129 }130 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);131 } else {132 // An update was scheduled on this fiber, but there are no new props133 // nor legacy context. Set this to false. If an update queue or context134 // consumer produces a changed value, it will set this to true. Otherwise,135 // the component will assume the children have not changed and bail out.136 didReceiveUpdate = false;137 }138 } else {139 didReceiveUpdate = false;140 } // Before entering the begin phase, clear the expiration time.141 workInProgress.expirationTime = NoWork;142 switch (workInProgress.tag) {143 case IndeterminateComponent: {144 return mountIndeterminateComponent(current$$1, workInProgress, workInProgress.type, renderExpirationTime);145 }146 case LazyComponent: {147 var elementType = workInProgress.elementType;148 return mountLazyComponent(current$$1, workInProgress, elementType, updateExpirationTime, renderExpirationTime);149 }150 case FunctionComponent: {151 var _Component = workInProgress.type;152 var unresolvedProps = workInProgress.pendingProps;153 var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps);154 return updateFunctionComponent(current$$1, workInProgress, _Component, resolvedProps, renderExpirationTime);155 }156 case ClassComponent: {157 var _Component2 = workInProgress.type;158 var _unresolvedProps = workInProgress.pendingProps;159 var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps);160 return updateClassComponent(current$$1, workInProgress, _Component2, _resolvedProps, renderExpirationTime);161 }162 case HostRoot:163 return updateHostRoot(current$$1, workInProgress, renderExpirationTime);164 case HostComponent:165 return updateHostComponent(current$$1, workInProgress, renderExpirationTime);166 case HostText:167 return updateHostText(current$$1, workInProgress);168 case SuspenseComponent:169 return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);170 case HostPortal:171 return updatePortalComponent(current$$1, workInProgress, renderExpirationTime);172 case ForwardRef: {173 var type = workInProgress.type;174 var _unresolvedProps2 = workInProgress.pendingProps;175 var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);176 return updateForwardRef(current$$1, workInProgress, type, _resolvedProps2, renderExpirationTime);177 }178 case Fragment:179 return updateFragment(current$$1, workInProgress, renderExpirationTime);180 case Mode:181 return updateMode(current$$1, workInProgress, renderExpirationTime);182 case Profiler:183 return updateProfiler(current$$1, workInProgress, renderExpirationTime);184 case ContextProvider:185 return updateContextProvider(current$$1, workInProgress, renderExpirationTime);186 case ContextConsumer:187 return updateContextConsumer(current$$1, workInProgress, renderExpirationTime);188 case MemoComponent: {189 var _type2 = workInProgress.type;190 var _unresolvedProps3 = workInProgress.pendingProps; // Resolve outer props first, then resolve inner props.191 var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);192 {193 if (workInProgress.type !== workInProgress.elementType) {194 var outerPropTypes = _type2.propTypes;195 if (outerPropTypes) {196 checkPropTypes(outerPropTypes, _resolvedProps3, // Resolved for outer only197 'prop', getComponentName(_type2), getCurrentFiberStackInDev);198 }199 }200 }201 _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);202 return updateMemoComponent(current$$1, workInProgress, _type2, _resolvedProps3, updateExpirationTime, renderExpirationTime);203 }204 case SimpleMemoComponent: {205 return updateSimpleMemoComponent(current$$1, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime);206 }207 case IncompleteClassComponent: {208 var _Component3 = workInProgress.type;209 var _unresolvedProps4 = workInProgress.pendingProps;210 var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);211 return mountIncompleteClassComponent(current$$1, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);212 }213 case SuspenseListComponent: {214 return updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime);215 }216 case FundamentalComponent: {217 if (enableFundamentalAPI) {218 return updateFundamentalComponent$1(current$$1, workInProgress, renderExpirationTime);219 }220 break;221 }222 case ScopeComponent: {223 if (enableScopeAPI) {224 return updateScopeComponent(current$$1, workInProgress, renderExpirationTime);225 }226 break;227 }228 }...
beginWork.js
Source:beginWork.js
...140 // same children then we're still in progressive loading state.141 // Something might get unblocked by state updates or retries in the142 // tree which will affect the tail. So we need to use the normal143 // path to compute the correct tail.144 return updateSuspenseListComponent(145 current,146 workInProgress,147 renderExpirationTime,148 );149 }150 // If none of the children had any work, that means that none of151 // them got retried so they'll still be blocked in the same way152 // as before. We can fast bail out.153 workInProgress.effectTag |= DidCapture;154 }155 // If nothing suspended before and we're rendering the same children,156 // then the tail doesn't matter. Anything new that suspends will work157 // in the "together" mode, so we can continue from the state we had.158 let renderState = workInProgress.memoizedState;159 if (renderState !== null) {160 // Reset to the "together" mode in case we've started a different161 // update in the past but didn't complete it.162 renderState.rendering = null;163 renderState.tail = null;164 }165 pushSuspenseContext(workInProgress, suspenseStackCursor.current);166 if (hasChildWork) {167 break;168 } else {169 // If none of the children had any work, that means that none of170 // them got retried so they'll still be blocked in the same way171 // as before. We can fast bail out.172 return null;173 }174 }175 }176 return bailoutOnAlreadyFinishedWork(177 current,178 workInProgress,179 renderExpirationTime,180 );181 } else {182 didReceiveUpdate = false;183 }184 } else {185 didReceiveUpdate = false;186 }187 workInProgress.expirationTime = NoWork;188 switch (workInProgress.tag) {189 case IndeterminateComponent: {190 return mountIndeterminateComponent(191 current,192 workInProgress,193 workInProgress.type,194 renderExpirationTime,195 );196 }197 case LazyComponent: {198 const elementType = workInProgress.elementType;199 return mountLazyComponent(200 current,201 workInProgress,202 elementType,203 updateExpirationTime,204 renderExpirationTime,205 );206 }207 case FunctionComponent: {208 const Component = workInProgress.type;209 const unresolvedProps = workInProgress.pendingProps;210 const resolvedProps =211 workInProgress.elementType === Component212 ? unresolvedProps213 : resolveDefaultProps(Component, unresolvedProps);214 return updateFunctionComponent(215 current,216 workInProgress,217 Component,218 resolvedProps,219 renderExpirationTime,220 );221 }222 case ClassComponent: {223 const Component = workInProgress.type;224 const unresolvedProps = workInProgress.pendingProps;225 const resolvedProps =226 workInProgress.elementType === Component227 ? unresolvedProps228 : resolveDefaultProps(Component, unresolvedProps);229 return updateClassComponent(230 current,231 workInProgress,232 Component,233 resolvedProps,234 renderExpirationTime,235 );236 }237 case HostRoot:238 return updateHostRoot(current, workInProgress, renderExpirationTime);239 case HostComponent:240 return updateHostComponent(current, workInProgress, renderExpirationTime);241 case HostText:242 return updateHostText(current, workInProgress);243 case SuspenseComponent:244 return updateSuspenseComponent(245 current,246 workInProgress,247 renderExpirationTime,248 );249 case HostPortal:250 return updatePortalComponent(251 current,252 workInProgress,253 renderExpirationTime,254 );255 case ForwardRef: {256 const type = workInProgress.type;257 const unresolvedProps = workInProgress.pendingProps;258 const resolvedProps =259 workInProgress.elementType === type260 ? unresolvedProps261 : resolveDefaultProps(type, unresolvedProps);262 return updateForwardRef(263 current,264 workInProgress,265 type,266 resolvedProps,267 renderExpirationTime,268 );269 }270 case Fragment:271 return updateFragment(current, workInProgress, renderExpirationTime);272 case Mode:273 return updateMode(current, workInProgress, renderExpirationTime);274 case Profiler:275 return updateProfiler(current, workInProgress, renderExpirationTime);276 case ContextProvider:277 return updateContextProvider(278 current,279 workInProgress,280 renderExpirationTime,281 );282 case ContextConsumer:283 return updateContextConsumer(284 current,285 workInProgress,286 renderExpirationTime,287 );288 case MemoComponent: {289 const type = workInProgress.type;290 const unresolvedProps = workInProgress.pendingProps;291 // Resolve outer props first, then resolve inner props.292 let resolvedProps = resolveDefaultProps(type, unresolvedProps);293 if (__DEV__) {294 if (workInProgress.type !== workInProgress.elementType) {295 const outerPropTypes = type.propTypes;296 if (outerPropTypes) {297 checkPropTypes(298 outerPropTypes,299 resolvedProps, // Resolved for outer only300 'prop',301 getComponentName(type),302 );303 }304 }305 }306 resolvedProps = resolveDefaultProps(type.type, resolvedProps);307 return updateMemoComponent(308 current,309 workInProgress,310 type,311 resolvedProps,312 updateExpirationTime,313 renderExpirationTime,314 );315 }316 case SimpleMemoComponent: {317 return updateSimpleMemoComponent(318 current,319 workInProgress,320 workInProgress.type,321 workInProgress.pendingProps,322 updateExpirationTime,323 renderExpirationTime,324 );325 }326 case IncompleteClassComponent: {327 const Component = workInProgress.type;328 const unresolvedProps = workInProgress.pendingProps;329 const resolvedProps =330 workInProgress.elementType === Component331 ? unresolvedProps332 : resolveDefaultProps(Component, unresolvedProps);333 return mountIncompleteClassComponent(334 current,335 workInProgress,336 Component,337 resolvedProps,338 renderExpirationTime,339 );340 }341 case SuspenseListComponent: {342 return updateSuspenseListComponent(343 current,344 workInProgress,345 renderExpirationTime,346 );347 }348 case FundamentalComponent: {349 if (enableFundamentalAPI) {350 return updateFundamentalComponent(351 current,352 workInProgress,353 renderExpirationTime,354 );355 }356 break;...
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false });4 const page = await browser.newPage();5 await page.evaluate((selector) => {6 const element = document.querySelector(selector);7 element.updateSuspenseListComponent();8 }, 'input[name="q"]');9 await page.waitForSelector('input[name="q"]');10 await browser.close();11})();
Using AI Code Generation
1const playwright = require('playwright');2const { updateSuspenseListComponent } = require('playwright/lib/server/supplements/recorder/recorderSupplement');3(async () => {4 const browser = await playwright.chromium.launch({ headless: false });5 const context = await browser.newContext();6 const page = await context.newPage();7 await updateSuspenseListComponent(page, 'google', { name: 'Google' });8 await browser.close();9})();10const { test, expect } = require('@playwright/test');11test('test', async ({ page }) => {12 const element = await page.waitForSelector('google');13 expect(element).toBeTruthy();14});
Using AI Code Generation
1const { updateSuspenseListComponent } = require('playwright/lib/server/supplements/recorder/recorderSupplement.js');2const { Page } = require('playwright');3const page = new Page();4updateSuspenseListComponent(page, 'myComponent', 'mySuspenseList');5updateSuspenseListComponent ( page : Page, componentName : string, suspenseList : string ) : Promise < void >6const { updateSuspenseListComponent } = require('playwright/lib/server/supplements/recorder/recorderSupplement.js');7const { Page } = require('playwright');8const page = new Page();9updateSuspenseListComponent(page, 'myComponent', 'mySuspenseList');
Using AI Code Generation
1const { updateSuspenseListComponent } = require('playwright/lib/protocol/protocol');2const { launch } = require('playwright');3(async () => {4 const browser = await launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.waitForSelector('input[title="Search"]');8 await updateSuspenseListComponent(page, 'input[title="Search"]', 'value', 'test');9 await page.screenshot({ path: 'example.png' });10 await browser.close();11})();12const { updateSuspenseListComponent } = require('playwright/lib/protocol/protocol');13const { launch } = require('playwright');14(async () => {15 const browser = await launch();16 const context = await browser.newContext();17 const page = await context.newPage();18 await page.waitForSelector('input[title="Search"]');19 await updateSuspenseListComponent(page, 'input[title="Search"]', 'value', value);20 await page.screenshot({ path: 'example.png' });21 await browser.close();22})();23const { updateSuspenseListComponent } = require('playwright/lib/protocol/protocol');24const { launch } = require('playwright');25(async () => {26 const browser = await launch();27 const context = await browser.newContext();28 const page = await context.newPage();29 await page.waitForSelector('input[title="Search"]');30 await updateSuspenseListComponent(page, 'input[
Using AI Code Generation
1const { chromium } = require('playwright');2const { updateSuspenseListComponent } = require('playwright/lib/server/suppressions');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.screenshot({ path: `example.png` });8 await browser.close();9})();10 at CDPSession.send (/home/ashish/Projects/playwright/playwright/lib/cjs/server/cjs/common/cjs/Connection.js:204:13)11 at async CDPSession.sendAndIgnoreError (/home/ashish/Projects/playwright/playwright/lib/cjs/server/cjs/common/cjs/Connection.js:249:22)12 at async CDPSession.sendAndIgnoreError (/home/ashish/Projects/playwright/playwright/lib/cjs/server/cjs/common/cjs/Connection.js:249:22)13 at async CDPSession.sendAndIgnoreError (/home/ashish/Projects/playwright/playwright/lib/cjs/server/cjs/common/cjs/Connection.js:249:22)14 at async CDPSession.sendAndIgnoreError (/home/ashish/Projects/playwright/playwright/lib/cjs/server/cjs/common/cjs/Connection.js:249:22)15 at async CDPSession.sendAndIgnoreError (/home/ashish/Projects/playwright/playwright/lib/cjs/server/cjs/common/cjs/Connection.js:249:22)16 at async CDPSession.sendAndIgnoreError (/home/ashish/Projects/playwright/playwright/lib/cjs/server/cjs/common/cjs/Connection.js:249:22)17 at async CDPSession.sendAndIgnoreError (/home/ashish/Projects/playwright/playwright/lib/cjs/server/cjs/common/cjs/Connection.js:249:22)18 at async CDPSession.sendAndIgnoreError (/home/ashish/Projects/playwright/playwright/lib/cjs/server/cjs/common/cjs/Connection.js:249:22)19 at async CDPSession.sendAndIgnoreError (/home/
Using AI Code Generation
1const { updateSuspenseListComponent } = require('playwright/lib/server/supplements/recorder/recorderSupplement.js');2updateSuspenseListComponent('test', 'test', 'test');3const { test } = require('@playwright/test');4const { updateSuspenseListComponent } = require('playwright/lib/server/supplements/recorder/recorderSupplement.js');5test('test', async ({ page }) => {6 await page.click('text=Get started');7 await page.click('text=Record a test');8 await page.click('text=Run the test');9 updateSuspenseListComponent('test', 'test', 'test');10});11import { test } from '@playwright/test';12import { updateSuspenseListComponent } from 'playwright/lib/server/supplements/recorder/recorderSupplement.js';13test('test', async ({ page }) => {14 await page.click('text=Get started');15 await page.click('text=Record a test');16 await page.click('text=Run the test');17 updateSuspenseListComponent('test', 'test', 'test');18});
Using AI Code Generation
1const { updateSuspenseListComponent } = require('playwright/lib/server/supplements/recorder/recorderSupplement');2updateSuspenseListComponent('test', 'test', 'test', 'test');3 at Object.<anonymous> (/home/abc/Downloads/playwright-test/test.js:3:44)4 at Module._compile (internal/modules/cjs/loader.js:1137:30)5 at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)6 at Module.load (internal/modules/cjs/loader.js:985:32)7 at Function.Module._load (internal/modules/cjs/loader.js:878:14)8 at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
Using AI Code Generation
1const { updateSuspenseListComponent } = require('playwright/lib/server/supplements/recorder/recorderSupplement');2const { Page } = require('playwright');3const page = Page.create();4const elementHandle = page.$(selector);5updateSuspenseListComponent(elementHandle, 'test', 'test');6const { updateSuspenseListComponent } = require('playwright/lib/server/supplements/recorder/recorderSupplement');7const { Page } = require('playwright');8const page = Page.create();9const elementHandle = page.$(selector);10updateSuspenseListComponent(elementHandle, 'test', 'test');11const { updateSuspenseListComponent } = require('playwright/lib/server/supplements/recorder/recorderSupplement');12const { Page } = require('playwright');13const page = Page.create();14const elementHandle = page.$(selector);15updateSuspenseListComponent(elementHandle, 'test', 'test');16const { updateSuspenseListComponent } = require('playwright/lib/server/supplements/recorder/recorderSupplement');17const { Page } = require('playwright');18const page = Page.create();19const elementHandle = page.$(selector);20updateSuspenseListComponent(elementHandle, 'test', 'test');21const { updateSuspenseListComponent } = require('playwright/lib/server/supplements/recorder/recorderSupplement');22const { Page } = require('playwright');23const page = Page.create();24const elementHandle = page.$(selector);25updateSuspenseListComponent(elementHandle, 'test', 'test');26const { updateSuspenseListComponent } = require('playwright/lib/server/supplements/recorder/recorderSupplement');27const { Page } = require('playwright');28const page = Page.create();
Using AI Code Generation
1const internalAPI = require("playwright/lib/server/frames");2internalAPI.updateSuspenseListComponent(3 page.mainFrame(),4);5internalAPI.updateSuspenseComponent(6 page.mainFrame(),7);8internalAPI.updateSuspenseComponent(9 page.mainFrame(),10);11internalAPI.updateSuspenseComponent(12 page.mainFrame(),13);14updateSuspenseComponent(frame, componentName, propName, value)15updateSuspenseListComponent(frame, componentName, propName, value)
Using AI Code Generation
1const { updateSuspenseListComponent } = require('playwright/lib/server/suppressions');2updateSuspenseListComponent([{3}]);4const { updateSuspenseListComponent } = require('playwright/lib/server/suppressions');5updateSuspenseListComponent([{6}]);7const { updateSuspenseListComponent } = require('playwright/lib/server/suppressions');8updateSuspenseListComponent([{9}]);10const { updateSuspenseListComponent } = require('playwright/lib/server/suppressions');11updateSuspenseListComponent([{12}]);13const { updateSuspenseListComponent } = require('playwright/lib/server/suppressions');14updateSuspenseListComponent([{15}]);16const { updateSuspenseListComponent } = require('playwright/lib/server/suppressions');17updateSuspenseListComponent([{18}]);19const { updateSuspenseListComponent } = require('playwright/lib/server/suppressions');20updateSuspenseListComponent([{21}]);22const { updateSuspenseListComponent } = require('playwright/lib/server/suppressions');23updateSuspenseListComponent([{24}]);25const { updateSuspenseListComponent } = require('playwright/lib/server/suppressions');26updateSuspenseListComponent([{27}]);28const { updateSuspenseListComponent } = require('playwright/lib/server/suppressions');29updateSuspenseListComponent([{
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!